1000 Hits
個半月就有1000hits。
多謝大家關心。
個半月就有1000hits。
多謝大家關心。
![]()
電影的tagline 是「life is waiting」,
生活是一次接一次的等待。
我說,生活應是一次接一次的期待,
等待是被動的,
而期待是主動的。
等待..不一定知道等什麼,
也不知道要怎面對。
等不是問題,
重點是知道自己要什麼,在等什麼,
不會因為你等待就送到你面前的,
自己想要什麼就要努力爭取。
我知道自己在等什麼,期待著,
同時我也找到很多我一直在等的。
一返唻香港就感受到各方面既壓力,
好難討好晒咁多面,
最怕係全部都唔討好。
由假期既天堂跌入地獄。
這一年太多重要的改變。
做過很多重要的決定,
雖然不曾後悔,
但絕大部份都是任性的。
感謝在我22歲這一年對我好的所有人,
也特別感謝朋友,
我明白一直很幸運受到很多關心,
今年的我覺得朋友是重要的。
也希望身邊的人原諒我這一年做過的任性事。
Finally i managed to get file upload works using a gwt-ext client against spring mvc.
In GWT application file upload is something different,
you cannot do so through GWT-RPC due to the browser implementation.
File upload is only achievable through multipart form post.
On the client side you have to set up a form:
final FormPanel formPanel = new FormPanel();
// setFileUpload(true) is important because it sets the
// <form>'s content type to multipart
// so that your server knows what to do
formPanel.setFileUpload(true);
final TextField file = new TextField("File", "file");
file.setInputType("file");
formPanel.add(file);
formPanel.addButton(new Button("Upload", new ButtonListenerAdapter() {
public void onClick(Button button, EventObject e) {
formPanel.getForm().submit(url, null, Connection.POST, "loading...", false);
}
}));
in the spring servlet config,
you will have to map the url you are POST-ing against to a controller that is responsible for handling file upload.
<!-- specify the java bean to bind the file upload as a byte array in the property 'commandClass" -->
<bean id="fileUploadController" class="example.server.FileUploadController">
<property name="commandClass" value="example.web.bean.FileUploadBean"/>
</bean>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/**/fileupload.smvc=fileUploadController
</value>
</property>
</bean>
<!-- this bean is how spring mvc detects multipart form post -->
<!-- commons-fileupload jar is required for this bean to work -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="100000"/>
</bean>
finally the controller code is easy,
at first I tried to subclass SimpleFormController,
but it involves specifying a formView and successView,
which, for a GWT client you are not going to need “view”.
so I simply extend the AbstractCommandController.
It binds the request parameters of a POST request to a commandClass,
this serves my purpose nicely.
public class FileUploadController extends AbstractCommandController {
protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
// you will need to cast the command back to your commandClass
FileUploadBean fileUploadBean = (FileUploadBean) command;
byte[] file = fileUploadBean.getFile();
// do whatever logic you needed
// because we are not going to return a "view"
// we simply have to give out some response to the GWT client and return a null view.
response.getWriter().println("File upload succeeded!");
return null;
}
// this method is overriding, and specify how spring convert multipart into a byte array that binds to our command class
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
super.initBinder(request, binder);
}
}
Integrating with spring mvc provides you free infrastructure of data binding, dependency injection on the controller,
and validation with spring’s Validator.
Hope this helps.
You could be my unintended choice to live my life extended
You could be the one I’ll always love
You could be the one who listens to my deepest inquisitions
You could be the one I’ll always love
I’ll be there as soon as I can
But I’m busy mending broken Pieces of the life I had before
First there was the one who challenged all my dreams and all my balance
She could never be as good as you
You could be my unintended choice to live my life extended
You should be the one I’ll always love
I’ll be there as soon as I can
But I’m busy mending broken Pieces of the life I had before
I’ll be there as soon as I can
But I’m busy mending broken Pieces of the life I had before
Before you
i can see the dark side of human from you.
don’t make me feel sick about.
…..and now i am sure you will never understand why things happened like this.

剛讀完這本RESTful Web Services。
其實本書不用寫那麼長,
概念上簡單不過,
REST 是一種網絡數據的設計方式,
簡化了傳統Web Service透過HTTP POST 作SOAP RPC請求的方法,
重新重視HTTP的設計原則。
換句話說就是純粹運用GET, PUT, DELETE等的HTTP方法完成一般對資料CRUD的操作。
本書一直重複這種方式的好處,
未免有點喋喋不休。
透過這種設計方式可以使網路系統更加簡單,
整合也更加容易。
市面上一些巨頭已經提供不少RESTful的Web Service,
如Google 的gmail, GData;Amazon的S3等,
証明了它本身的技術價值。
我是很欣賞這種設計風格,
不過呢...
目前Java 圈子內主流的application framework對REST的支持還不足,
例如根據Spring非正式的roadmap,
對REST的支持大約要到3.0才會開始,
相信要到08年尾才會看到些端倪(還不知支持到什麼程度)。
平民化的開源framework RESTlet 似乎還沒有完整的整合到其他application framework,
JCP311(就是Java REST標準)還在緩慢進行中...
目前REST在Java界不算很成熟,
似乎要用在企業級開發還是言之尚早,
至於internet website,
Ruby on Rails, Django輕量化的平台看來有不錯的支持,
寫起來會更方便。