zoukankan      html  css  js  c++  java
  • Struts2--Result类型

    4种 result类型: dispatcher, redirect, chain, redirectAction

    dispatcher, redirect只能跳转到jsp等页面

    chain,redirectAction是专门跳转到action页面的

    dispatcher,chain 是服务器端跳转

    redirect,redirectAction是客户端跳转

    总结;:

    dispatcher: 默认, 服务器跳转, 只能接jsp等页面

    redirect: 客户端跳转, 只能接jsp等页面

    chain: 服务器端调转, 可以接action

    redirectAction: 客户端跳转, 可以接action

    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>
        <constant name="struts.devMode" value="true" />
        <package name="resultTypes" namespace="/r" extends="struts-default">
    	    <action name="r1">
    	    	<result type="dispatcher">/r1.jsp</result>
    	    </action>
    	    
    	    <action name="r2">
    	    	<result type="redirect">/r2.jsp</result>
    	    </action>
    	    
    	    <action name="r3">
    	    	<result type="chain">r1</result>
    	    </action>
    	    
    	    <action name="r4">
    	    	<result type="redirectAction">r2</result>
    	    </action>
    	    
        </package>
    </struts>
    

    jsp:

         <li><a href="r/r1">dispatcher</a></li> 
    	<li><a href="r/r2">redirect</a></li>
    	<li><a href="r/r3">chain</a></li>
    	<li><a href="r/r4">redirectAction</a></li>
    

    dispacher: url: r/r1            显示r1

    redirect:    url: r2.jsp        显示r2

    chain:       url: r/r3             显示r1

    redirectAction: r2.jsp       显示r2

    如果r1在别的包如何处理?

     <action name="r3">
      <result type="chain">r1</result>
    </action>
     <action name="r3">
      <result type="chain">
        <param name="actionname">dash</param>
        <param name="namespace">/pack</param>
      </result> </action>

      

     

  • 相关阅读:
    1.SQL
    3.Dynamic Layout 动态布局。在槽中处理布局
    2.Border Layout 自定义一个Layout来完成布局。
    2.QWidget类
    eclipse内存设置,tomcat内存设置,查看内存大小
    java面试笔记
    java面试总结-(hibernate ibatis struts2 spring)
    jQuery属性,方法操作
    spring scope
    IOC原理解释
  • 原文地址:https://www.cnblogs.com/wujixing/p/5202829.html
Copyright © 2011-2022 走看看