<?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.devMode" value="false" />
<package name="shop" namespace="/" extends="struts-default">
<!-- 配置首页访问的action -->
<action name="index" class="indexAction">
<result name="index">/WEB-INF/jsp/index.jsp</result>
</action>
<!-- 配置访问注册的action -->
<action name="user_*" class="userAction" method="{1}">
<result name="registPage">/WEB-INF/jsp/regist.jsp</result>
</action>
</package>
</struts>
这个是applicationContext的配置
<!-- Action的配置 ===========================-->
<!-- 首页访问的Action -->
<bean id="indexAction" class="in.itcast.shop.index.action.IndexAction" scope="prototype">
</bean>
<!-- 配置验证码Action -->
<!-- 用户模块的Action -->
<bean id="userAction" class="in.itcast.shop.user.action.UserAction" scope="prototype">
<!-- 注入Service -->
</bean>
这是web.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="
http://java.sun.com/xml/ns/javaee"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 配置Spring的核心监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 配置Struts2的核心过滤器 -->
<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>
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
package in.itcast.shop.index.action;
import com.opensymphony.xwork2.ActionSupport;
/*
* 引入首页访问Action
*/
public class IndexAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
public String execute(){
return "index";
}
}