<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
然后在工程的src下新建一个struts.xml,并进行配置,注意版本号:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.multipart.maxSize" value="10701096" /><!--限制文件上传的大小 -->
<package name="User" namespace="/" extends="struts-default">
<action name="*_*" class="com.aode.action.{1}Action" method= "{2}" >
<result name="loginsucc">index.jsp</result>
<result name="succ">/index.jsp</result>
</action>
</package>
</struts>
最后再新建一个普通的java类,返回值为String即可。