`
akunamotata
  • 浏览: 374541 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

result type “redirect-action” Tomcat报异常问题

阅读更多

  启动Tomcat发现如下异常:

Unable to load configuration. - action - file:/D:/.../classes/struts.xml:9:66

  后来发现问题出现在result的结果类型"redirect-action",因为当前使用的Struts2版本使用的是如下结果类型:

<result-types>
    <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
    <result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>
    <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
    <result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/>
    <result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>
    <result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
    <result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>
    <result-type name="velocity" class="org.apache.struts2.dispatcher.VelocityResult"/>
    <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
    <result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" />
</result-types>

  其实"redirect"也可以实现action的重定向,最大的区别在于"redirect"需要写URL pattern,"redirectAction"是以配置方式来重定向的(当然也可以URL pattern方式),Struts2推荐使用"redirectAction"方式重定向到action。

 

   配置方式:

<result name="error" type="redirectAction">
    <param name="actionName">Register</param>
    <param name="username">${username}</param>
</result>

 

  URL方式:

 

 

<result name="error" type="redirectAction">
    <param name="actionName">Register?username=${username}</param>
</result>

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics