当前位置: 代码迷 >> Web前端 >> Struts2项目struts.xml跟web.xml配置
  详细解决方案

Struts2项目struts.xml跟web.xml配置

热度:106   发布时间:2012-11-21 08:23:26.0
Struts2项目struts.xml和web.xml配置
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.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
</web-app>





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>
	<package name="student" namespace="/jsp" extends="struts-default,json-default">
		<action name="login" class="com.cvicse.student.action.LoginAction" method="login">
			<result name="success">../index.jsp</result>
			<result name="fail">login.jsp</result>
		</action>
		<action name="register" class="com.cvicse.student.action.RegisterAction" method="register">
			<result name="success">register.jsp</result>
		</action>
		<action name="stuInfo" class="com.cvicse.student.action.StudentInfoAction" method="editStuInfoInit">
			<result name="success">./personinfo/personInfo.jsp</result>
		</action>
		<action name="headPortrait" class="com.cvicse.student.action.HeadPortraitAction" method="initUploadPic">
			<result name="success">./personinfo/uploadPicture.jsp</result>
			<result name="picSuccess">./personinfo/uploadPicture.jsp</result>
			<result name="picError">./personinfo/uploadPicture.jsp</result>
		</action>
		<action name="showPicture" class="com.cvicse.student.action.HeadPortraitAction" method="showPicture">
			<result type="json">
				<param name="root">picName</param>
			</result>
		</action>
	</package>
</struts>

  相关解决方案