Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1148414
  • 博文数量: 234
  • 博客积分: 5592
  • 博客等级: 大校
  • 技术积分: 1987
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-23 14:12
文章分类

全部博文(234)

文章存档

2015年(1)

2013年(4)

2012年(16)

2011年(204)

2010年(9)

分类: Java

2011-06-10 15:14:06

Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;}

一.struts2.xml result type属性说明

 

1.chain:用来处理Action链,被跳转的action中仍能获取上个页面的值,如request信息。   

    com.opensymphony.xwork2.ActionChainResult   

  

2.dispatcher:用来转向页面,通常处理JSP   

    org.apache.struts2.dispatcher.ServletDispatcherResult   

  

3.freemaker:处理FreeMarker模板   

    org.apache.struts2.views.freemarker.FreemarkerResult   

  

4.httpheader:控制特殊HTTP行为的结果类型  

    org.apache.struts2.dispatcher.HttpHeaderResult  

 

5.stream:向浏览器发送InputSream对象,用来处理文件下载,还可用于返回AJAX数据   

    org.apache.struts2.dispatcher.StreamResult   

  

6.velocity :处理Velocity模板   

    org.apache.struts2.dispatcher.VelocityResult   

  

7.xsl

    处理XML/XLST模板   

    org.apache.struts2.views.xslt.XSLTResult   

  

8.plainText:显示原始文件内容,例如文件源代码   

    org.apache.struts2.dispatcher.PlainTextResult   

  

9.plaintext:显示原始文件内容,例如文件源代码   

    org.apache.struts2.dispatcher.PlainTextResult

 

10.redirect:重定向到一个URL ,被跳转的页面中丢失传递的信息,如request 

    org.apache.struts2.dispatcher.ServletRedirectResult   

  

11.redirectAction :重定向到一个Action ,跳转的页面中丢失传递的信息,如request     

    org.apache.struts2.dispatcher.ServletActionRedirectResult   

  

12.redirect-action:重定向到一个Action ,跳转的页面中丢失传递的信息,如request     

    org.apache.struts2.dispatcher.ServletActionRedirectResult

 

 

 

 

 

 

二.redirectredirect-action区别

 

一、使用redirect需要后缀名 使用redirect-action不需要后缀名

二、type="redirect" 的值可以转到其它命名空间下的action,redirect-action只能转到同一命名空下的 action,因此它可以省略.action的后缀直接写action的名称。如:

 

viewTask.action

viewTask

 

附:redirect-action 传递参数

 

Xml代码

  class = "preinfoBusinessAction"  method = "enterPreinfoSub" >   

   < result   name = "success"   type = "redirect -action" >   

    showpreinfo?preinfo.order_number=${preinfo.order_number}&preinfo.company_name =${preinfo.company_name}   

      

  < result   name = "error"   type = "redirect " >   

     < param   name = "location" > /error.jsp    

     

 

 

   因为使用了redirect -action,所以要注意不能将 showpreinfpreinfo.order_number=${preinfo.order_number}写成 showpreinf.actionpreinfo.order_number=${preinfo.order_number}

 

其中${}EL表达式,获取actionenterpreinfo中属性的值 在这个配置文件里,多个参数的连接符使用了"&",但XML的语法规范,应该使用"&"代替"&",原理和HTML中的转义相同,开始没有注意,在struts 分析配置文件时,总是报出这样的错误:

 

The reference to entity  "preinfo"  must end with the  ';'  delimiter.  

The reference to entity "preinfo" must end with the ';' delimiter.

 

进行上面说明的替换后,就正常了。

 

阅读(944) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~