struts2 “No result defined for action and result input”的问题

kaka20014 2012-07-24 09:52:55
google+baidu都没有搞定,遗留的问题了。今天又碰到,就发来请教高手。
不是路径的问题也不是页面的属性和action中的属性类型不匹配!!!


<action name="updateGallery" class="galleryAction" method="updateGallery">
<result >/gallery/fetchAllGallery.action?gallery.uid=${gallery.uid}</result>
<!-- <result type="redirect">/gallery/fetchAllGallery.action?gallery.uid=${gallery.uid}</result>-->
</action>

当<result >/gallery/fetchAllGallery.action?gallery.uid=${gallery.uid}</result>写成这个时就会报上面的错误。跟踪调试返回的是SUCCESS,操作成功!不知道为什么报错
当<result type="redirect">/gallery/fetchAllGallery.action?gallery.uid=${gallery.uid}</result>写成这个时就不报错哦了!
很纳闷。想弄明白这个为什么?分只有20分,望高手指教
...全文
331 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
kaka20014 2012-07-25
  • 打赏
  • 举报
回复
高手帮我看看问题吧!不然绝对超级难受!
xiliang_lin 2012-07-24
  • 打赏
  • 举报
回复
<result name="success" type="redirect" >/gallery/fetchAllGallery.action?gallery.uid=${gallery.uid}</result>
<result name="input">/add.jsp</result>

这个试试看
kaka20014 2012-07-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

<action name="updateGallery" class="galleryAction" method="updateGallery">
<result type="success">/gallery/fetchAllGallery.action</result>
<result name="input">/add.jsp</result>
<result ……
[/Quote]
可以这样传值的,我是野路子摸索的。我的是action如果成功的话,转到另一个action中,但是第二个action中要一个参数,所以这样传了。大哥你说的放在action中怎么读取?拜谢
kaka20014 2012-07-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

额....你这是由一个action传值到另外的action啊!当然要用重定向。
要是你成功后直接转到一页面,就不需要用redirect
[/Quote]
struts2文档说的是action转向另action,推荐用redirect或redirect-action,但是我有时用dispatcher也有用的,这也是我的一个疑问?
kaka20014 2012-07-24
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

额....你这是由一个action传值到另外的action啊!当然要用重定向。
要是你成功后直接转到一页面,就不需要用redirect
[/Quote]
官方文档action转到另action 用redirect或redire-action但是我用dispatcher 也有用的。所以这也是疑问。
五哥 2012-07-24
  • 打赏
  • 举报
回复
<action name="updateGallery" class="galleryAction" method="updateGallery">
<result type="redirect">/gallery/fetchAllGallery.action</result>
<result name="input">/add.jsp</result>
<result name="error">/error.jsp</result>
</action>

?gallery.uid=${gallery.uid} --这个属性直接放到action中读取不就行了,还能这样子传 ?》
五哥 2012-07-24
  • 打赏
  • 举报
回复
<action name="updateGallery" class="galleryAction" method="updateGallery">
<result type="success">/gallery/fetchAllGallery.action</result>
<result name="input">/add.jsp</result>
<result name="error">/error.jsp</result>
</action>

?gallery.uid=${gallery.uid} --这个属性直接放到action中读取不就行了,还能这样子传 ?》
NoTargetException 2012-07-24
  • 打赏
  • 举报
回复
额....你这是由一个action传值到另外的action啊!当然要用重定向。
要是你成功后直接转到一页面,就不需要用redirect
kaka20014 2012-07-24
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 的回复:]

action间跳转需要加type标注是服务器间跳转还是客户端跳转。现在你的疑惑是什么?
[/Quote]
大哥的意思是:如果不加resultType 就会出错吗?我本来也是这样认为的。但是

<action name="draftBlog" class="blogAction" method="draftBlog">
<result>/blog/showAllDraft.action?uid=${blog.uid}</result>
</action>

这是我项目中的,也可以跳转的!疑惑就是这个。如果直接不能跳转就算了,有了一次,就不爽,搞不懂什么原因
「已注销」 2012-07-24
  • 打赏
  • 举报
回复
action间跳转需要加type标注是服务器间跳转还是客户端跳转。现在你的疑惑是什么?
kaka20014 2012-07-24
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 的回复:]

配置错误了在action的 方法里 是要有返回值的 比如 updateGallery方法返回 success 对应在 xml里配置 result name="success"
<result name="success">index.jsp</result>这样就可以了
但你这个是重定向要加一个type
<result name="success" type="redirectac……
[/Quote]
struts2默认name的属性值就是"success"啊。不写和写有区别吗?我刚才加了name属性但还是报错!还请帮忙,这个问题我做项目一开始的时候就遇到了。出现了不止一次,发来求高手解疑!
BlueSky66666 2012-07-24
  • 打赏
  • 举报
回复
<action name="updateGallery" class="galleryAction" method="updateGallery">
<result name="success" type="redirectAction">
<param name="actionName">fetchAllGallery</param>
<param name="namespace">/gallery</param>
<param name="gallery.uid">${gallery.uid}</param>
</result>
</action>
a512796048 2012-07-24
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 的回复:]

配置错误了在action的 方法里 是要有返回值的 比如 updateGallery方法返回 success 对应在 xml里配置 result name="success"
<result name="success">index.jsp</result>这样就可以了
但你这个是重定向要加一个type
<result name="success" type="redirectac……
[/Quote]
补充下这个 你要加参数的话这样<request name="success" type="redirect"><result >/gallery/fetchAllGallery.action?gallery.uid=${gallery.uid}</result>
a512796048 2012-07-24
  • 打赏
  • 举报
回复
配置错误了在action的 方法里 是要有返回值的 比如 updateGallery方法返回 success 对应在 xml里配置 result name="success"
<result name="success">index.jsp</result>这样就可以了
但你这个是重定向要加一个type
<result name="success" type="redirectaction">这里是你action的名字updateGallery</result>
还有
<result name="success" type="redirect">updateGallery这里要加.action</result>
就是说redirect要写一个完整的请求路径而redirectaction写action的名字就可以。
kaka20014 2012-07-24
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]

<result name="success" type="redirect" >/gallery/fetchAllGallery.action?gallery.uid=${gallery.uid}</result>
<result name="input">/add.jsp</result>

这个试试看
[/Quote]
加一个input 视图也没有用的

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧