web.xml
| <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> |
struts.xml
| <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> |
upload.jsp
|
<%...@ page language="java" contentType="text/html; charset=GB18030" <%...@ page language="java" contentType="text/html; charset=GB18030" package com.xie.struts.upload; import java.io.File; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionSupport; public class UploadAction extends ActionSupport ...{ private File file; private String fileFileName; // 有属性file+Filename固定组成 private String fileContentType; // 有属性file+ContentType固定组成 public String getUsername() ...{ public void setUsername(String username) ...{ public File getFile() ...{ public void setFile(File file) ...{ public String getFileFileName() ...{ public void setFileFileName(String fileFileName) ...{ public String getFileContentType() ...{ public void setFileContentType(String fileContentType) ...{ @Override |

