1 随着struts2的改版,现在改的越来越乱了,用了很多自己的东西,要导入的包越来越多了,截下图吧,感觉越来越不好用了,这9个缺一不可
2 主配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<filter>
<filter-name>struts2</filter-name>
<!--
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>--><!-- -->
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<!-- FilterDispatcher用来初始化struts2并且处理所有的WEB请求。 -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<!-- <url-pattern>*.action</url-pattern> -->
</filter-mapping>
<display-name>ss2</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
这里面有 原先的配置和后来的,新的jia肯定不再适合原来的主类了
3 src下建立struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="main" extends="struts-default" >
<action name="mainAction" class="com.YCHZ.jquery.action.LoginAction"
method="execute">
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
4 建立action
package com.YCHZ.jquery.action;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
public String execute()
{
System.out.println("ok");
return SUCCESS;
}
}