码迷,mamicode.com
首页 > 其他好文 > 详细

struts中的重定向转发功能配置文件的撰写

时间:2018-06-26 20:42:50      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:support   pack   错误   pac   utf-8   开发   over   hello   撰写   

//Demo1Action.java

package com.struts.a_result;

import com.opensymphony.xwork2.ActionSupport;

public class Demo1Action extends ActionSupport {
	
	
	@Override
	public String execute() throws Exception {

		return "SUCCESS";
	}
	
	

}

//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>
	<!-- 可配置的常量 -->
	<!-- i18n:国际化  解决post的提交乱码和输出中文乱码 -->
	<constant name="struts.i18n.encoding" value="UTF-8"></constant>
	<!-- 指定反问action时的后缀名 
		http://localhost:8080/Struts2_test1/hello/HelloAction.xhtml
	-->
	<constant name="struts.action.extension" value="action"></constant>
	<!-- 指定struts2是否以开发模式运行
			1.热加载主配置.(不需要重启即可生效)
			2.提供更多错误信息输出,方便开发时的调试
	 -->
	<constant name="struts.devMode" value="true"></constant>
	
	<package name="SSDA1" namespace="/" extends="struts-default" >
	
		<action name="Demo1Action" class="com.struts.a_result.Demo1Action" method="execute" >
			<result name="SUCCESS" type="dispatcher" >/hello.jsp</result><!-- type="dispatcher" 默认为转发 -->
		</action>
		
		<!-- 重定向 -->
		<action name="Demo2Action" class="com.struts.a_result.Demo2Action" method="execute" >
			<result name="SUCCESS" type="redirect" >/hello.jsp</result><!-- type="dispatcher" 默认为转发 -->
		</action>
		
		<!-- 重定向到Action -->
		<action name="Demo3Action" class="com.struts.a_result.Demo3Action" method="execute" >
			<result  name="SUCCESS"  type="redirectAction">
				 <!-- action的名字 -->
	             <param name="actionName">Demo1Action</param>
	             <!-- action所在的命名空间 -->
	             <param name="namespace">/</param>
            </result>
		</action>
		
		
	</package>
	
	
	
	<!-- <include file=""></include>com/struts2/b_dynamic/struts.xml -->
</struts>

  

 

struts中的重定向转发功能配置文件的撰写

标签:support   pack   错误   pac   utf-8   开发   over   hello   撰写   

原文地址:https://www.cnblogs.com/Terlong/p/9231001.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!