Action中result的各种转发类型

Action中result的各种转发类型

1,dispatcher:默认值  ,内部定向

<result>/WEB-INF/page/employeeAdd.jsp</result>

2,redirect:浏览器重定向

<result type="redirect">/index.jsp</result>

3, redirectAction 重定向到action
//同一个包下的
<result type="redirectAction">actionname</result>
//不同包下的
<result type="redirectAction">
  <param name="actionName">XXX</param>
  <param name="namespace" >XXX</param>

</result> 

4, plainText:输出视图的代码
<result type="plainText">/index.jsp</result>
//指定编码
<result type="plainText">
   <param name="location">/index.jsp</param>
   <param name="charSet">UTF-8</param>

</result>

5,<global-results>  全局视图
//为了能让所有的包,都可以使用该视图
<package name="base" extends="struts-default">
    <global-results >
<result name="message">/WEB-INF/page/message.jsp</result>
    </global-results>
</package>
//然后其他包继承该包就可以了

6,为action注入属性值
<action name="helloworld" class="cn.itcast.action.HelloWorldAction" method="execute" >
  <param name="savepath">/image</param>
  <result name="success">/WEB-INF/page/MyJsp.jsp</result>
</action>//这样hellowoldAction 中的savapath属性值就是/image

原文地址:https://www.cnblogs.com/feifeicui/p/8728658.html

时间: 2024-08-03 12:07:29

Action中result的各种转发类型的相关文章

【Struts2学习笔记(2)】Action配置中的各项默认值和Action中result的各种转发类型

一.Action配置中的各项默认值 <span style="font-size:18px;"><package name="itcast" namespace="/test" extends="struts-default"> <action name="helloworld" class="cn.itcast.action.HelloWorldAction&quo

action中result没有值

action中result没有值,访问action会输出action中的所有数据,输出类型为.action类型 .

struts学习笔记(3)---Action中访问ServletAPI获取真实类型的元素

一.源代码: 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"> <

Action中访问ServletAPI获取Map类型的Servlet元素

源代码: strust.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"> <strut

【Struts2学习笔记(2)】Action默认值和配置Action于result各种转发类型

一.Action缺省配置值 <span style="font-size:18px;"><package name="itcast" namespace="/test" extends="struts-default"> <action name="helloworld" class="cn.itcast.action.HelloWorldAction" m

Struts2中Action各种转发类型

Struts2:Action中result的各种转发类型: 内部请求转发dispatcher(默认值) redirect.redirectAction.plainText1.redirect是重定向到某个路径.视图<action name="redirect">/***重定向   <result type="redirect">/employeeAdd.jsp?username=${username}</result></a

Struts2中 Result类型配置详解(转)

一个result代表了一个可能的输出.当Action类的方法执行完成时,它返回一个字符串类型的结果码,框架根据这个结果码选择对应的result,向用户输出.在com.opensymphony.xwork2.Action接口中定义了一组标准的结果代码,可供开发人员使用,当然了只有我们的action继承ActionSupport 这个类才可以使用下面的结果代码,如下所示:public interface Action{    public static final String SUCCESS =

Struts2中 Result类型配置详解

一个result代表了一个可能的输出.当Action类的方法执行完成时,它返回一个字符串类型的结果码,框架根据这个结果码选择对应的result,向用户输出. 在com.opensymphony.xwork2.Action接口中定义了一组标准的结果代码,可供开发人员使用,当然了只有我们的action继承ActionSupport 这个类才可以使用下面的结果代码,如下所示: public interface Action {     public static final String SUCCES

【strust】strust.xml中&lt;result type=&quot;&quot;&gt;所有类型详解

在默认时,<result>标签的type属性值是“dispatcher”(实际上就是转发,forward).开发人员可以根据自己的需要指定不同的类型,如redirect.stream等.如下面代码所示: <result name="save" type="redirect"> /result.jsp </result> 这时result-type可以在struts2-core-2.0.11.1.jar包或struts2源代码中的s