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>
	<package name="default" namespace="/" extends="json-default">

		<interceptors>
			<interceptor name="login" class="loginInterceptor" />
			<interceptor name="public" class="publicInterceptor" />
			<interceptor-stack name="myStack">
				<interceptor-ref name="defaultStack" />
				<interceptor-ref name="login" />
			</interceptor-stack>
		</interceptors>

		<global-results>
			<result name="error">/WEB-INF/pages/error.jsp</result>
		</global-results>

		<action name="*">
			<result>/WEB-INF/pages/{1}.jsp</result>
			<interceptor-ref name="public">
				<param name="allowType">login,register</param>
			</interceptor-ref>
			<result name="login" type="redirectAction">login.action</result>
		</action>

		<action name="loginpost" class="loginPostAction">
			<result type="redirectAction">/json/Login_Json.action</result>
			<interceptor-ref name="myStack" />
			<result name="input" type="redirectAction">/json/Login_Json.action</result>
			<result name="error">/WEB-INF/pages/login.jsp</result>
		</action>

		<action name="registerpost" class="registerPostAction">
			<result>/WEB-INF/pages/registersuccess.jsp</result>
			<result name="input">/WEB-INF/pages/register.jsp</result>
			<result name="error">/WEB-INF/pages/register.jsp</result>
		</action>


		<action name="test" class="testAction">
			<result type="chain">login</result>
		</action>


		<action name="pactack" class="partackAction">
			<result>/WEB-INF/pages/pactack.jsp</result>
			<result name="none">/WEB-INF/pages/pactackresult.jsp</result>
			<result name="input">/WEB-INF/pages/vote_update.jsp</result>
		</action>

		<action name="image" class="imageAction">
			<result name="success">/WEB-INF/pages/login.jsp</result>
		</action>

		<action name="logout" class="partackAction" method="logout">
			<result type="redirectAction">login.action</result>
		</action>

		<action name="pactackresult" class="pactackResultAction">
			<result>/WEB-INF/pages/pactackresult.jsp</result>
			<result name="none">/WEB-INF/pages/pactacksuccess.jsp</result>
		</action>

	</package>

	<package name="json" namespace="/json" extends="json-default">
		<action name="*_*" class="com.znsd.vote.json.{1}{2}">
			<result type="json">
				<!--指定将被Struts2序列化的属性,在action中必须有对应的getter方法 -->
				<param name="root">map</param>
			</result>
			<result name="input" type="json">
				<!--指定将被Struts2序列化的属性,在action中必须有对应的getter方法 -->
				<param name="root">map</param>
			</result>
		</action>
		<action name="loginpostJson"
			class="com.znsd.vote.json.LoginJson" method="login">
			<result type="json">
				<!--指定将被Struts2序列化的属性,在action中必须有对应的getter方法 -->
				<param name="root">map</param>
			</result>
			<result name="input" type="json">
				<!--指定将被Struts2序列化的属性,在action中必须有对应的getter方法 -->
				<param name="root">map</param>
			</result>
		</action>
	</package>
</struts>
上一篇:java – Struts 2是否可用作OSGi包?


下一篇:java – Spring注入Struts RequestProcessor