EXTJS配合Struts2的图片上传(可预览)
3. import javax.servlet.http.HttpServletRequest;
4. import javax.servlet.http.HttpServletResponse;
5.
6. import org.apache.struts2.interceptor.ServletRequestAware;
7. import org.apache.struts2.interceptor.ServletResponseAware;
8.
9. import cn.com.ajaxbear.vo.Account;
10.
11. import com.opensymphony.xwork2.ActionSupport;
12.
13. public class BaseAction extends ActionSupport implements ServletRequestAware,
14. ServletResponseAware {
15. private static final long serialVersionUID = -1513311332990213727L;
16.
17. protected HttpServletResponse response;
18.
19. protected HttpServletRequest request;
20.
21. public void setServletRequest(HttpServletRequest request) {
22. this.request = request;
23. }
24.
25. public void setServletResponse(HttpServletResponse response) {
26. this.response = response;
27. }
28.
29. protected Account getUser(HttpServletRequest request){
30. return (Account)request.getSession().getAttribute("user");
31. }
32.
33. protected void setUser(HttpServletRequest request, Account account){
34. request.getSession().setAttribute("user", account);
35. }
36.
37. protected void destroyUser(HttpServletRequest request){
38. request.getSession().removeAttribute("user");
39. }
40.
41. }
package cn.com.ajaxbear.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.interceptor.ServletRequestAwarutStream;
5. import java.io.FileOutputStream;
6. import java.util.UUID;
7.
8. import org.apache.struts2.ServletActionContext;
9.
10. import cn.com.ajaxbear.util.XResponse;
11.
12. public class UploadAction extends BaseAction {
13.
14. private File upload;
15. private String uploadContentType;
16. public File getUpload() {
17. return upload;
18. }
19.
20. public void setUpload(File upload) {
21.