求助struts2 配置的action路径找不到

a107494639 2011-04-15 12:25:55
struts.xml中的这action配置:
<!-- 更新类别信息-->

<!-- 更新类别信息-->
<action name="updateSortInfo" class="org.actions.DevSortAction" method="updateSortInfo">
<result name="success">/jsp/sort/showSorts.jsp</result>
</action>

action类中的这个方法:

public String updateSortInfo(){
System.out.println("aa");
if(sortServices.updateSort(this.devSort)){
return this.SUCCESS;
}
this.request.setAttribute("errorMsg", "数据库连接失败或者该名称已经存在");
return this.ERROR;
}

jsp页面中的form表单:

<FORM action="updateSortInfo.action" method="get" name="myform">
里面省略了内容,里面有个提交按钮
</FORM>


报错的信息是:
严重: Could not find action or result
No result defined for action org.actions.DevSortAction and result input - action - file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/devManage/WEB-INF/classes/struts.xml:119:91


我的代码中的aa没有打印出来,说明没有进这个方法。可是这个action中我我还写了其他8,9个方法,都一直没问题。今天写这个方法的时候突然进不来了,真是奇怪。
...全文
427 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
ycxiaobao 2012-05-26
  • 打赏
  • 举报
回复
org.actions.DevSortAction 改成 org.struts.actions.DevSortAction会好的
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 ylz2007 的回复:]

引用 10 楼 a107494639 的回复:

发现配置input后,点击提交,没进方法,直接跳到input对应的页面。。。
XML code

<!-- 更新类别信息-->
<action name="updateSortInfo" class="org.actions.DevSortAction" method="updateSortInfo">
<result name="……
[/Quote]

方法抛出异常,加throws Exception,跟踪下看看就知道了
xiao_kan_hong_chen 2011-04-15
  • 打赏
  • 举报
回复
配置文件中<package>中namespace="/test" 然后form中test/updateSortInfo.action
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 a107494639 的回复:]

发现配置input后,点击提交,没进方法,直接跳到input对应的页面。。。
XML code

<!-- 更新类别信息-->
<action name="updateSortInfo" class="org.actions.DevSortAction" method="updateSortInfo">
<result name="success">/……
[/Quote]

看看后台报了神马异常
a107494639 2011-04-15
  • 打赏
  • 举报
回复
发现配置input后,点击提交,没进方法,直接跳到input对应的页面。。。

<!-- 更新类别信息-->
<action name="updateSortInfo" class="org.actions.DevSortAction" method="updateSortInfo">
<result name="success">/jsp/sort/showSorts.jsp</result>
<result name="input">/jsp/sort/updateSort.jsp</result>
</action>
xiao_kan_hong_chen 2011-04-15
  • 打赏
  • 举报
回复
先试试 看一下结果再说
a107494639 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 xiao_kan_hong_chen 的回复:]
错误信息是你没有定义<result name="input"></result>也就是出错了,你可以设断点调试一下,看有没有执行到该方法。
[/Quote]
可是我其他action都没有配置input的,为什么都可以用的,那个方法是没有进去的。

<package name="devSort" extends="base">
<!-- 添加类别 -->
<action name="addSort" class="org.actions.DevSortAction" method="addSort">
<result name="success">/jsp/sort/showSorts.jsp</result>
</action>
<!-- 查询一二级类别-->
<action name="querySortLevel" class="org.actions.DevSortAction" method="querySortLevel">
</action>
<!-- 查询所有类别-->
<action name="queryDevSorts" class="org.actions.DevSortAction" method="queryDevSorts">
</action>
<!-- 通过类别查询-->
<action name="queryBySort" class="org.actions.DevSortAction" method="queryBySort">
</action>
<!-- 通过名称查询-->
<action name="queryByName" class="org.actions.DevSortAction" method="queryByName">
</action>
<!-- 删除类别-->
<action name="deleteSort" class="org.actions.DevSortAction" method="deleteSort">
</action>
<!-- 通过某个上级类别查找其下的类别-->
<action name="querySortByUpLevel" class="org.actions.DevSortAction" method="querySortByUpLevel">
</action>
<!-- 查询某个类别信息后更新-->
<action name="queryDevSortForUpdate" class="org.actions.DevSortAction" method="queryDevSortForUpdate">
<result name="success">/jsp/sort/updateSort.jsp</result>
</action>
<!-- 更新类别信息-->
<action name="updateSortInfo" class="org.actions.DevSortAction" method="updateSortInfo">
<result name="success">/jsp/sort/showSorts.jsp</result>
</action>
</package>
a107494639 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 hzhj90 的回复:]
请用绝对路径,这样最保险。
不用绝对路径,经常会找不到。
[/Quote]
我把路径该为

<FORM action="http://localhost:8080/devManage/updateSortInfo.action" method="get" name="myform"></FORM>

结果还是一样:
HTTP Status 404 - No result defined for action org.actions.DevSortAction and result input

--------------------------------------------------------------------------------

type Status report

message No result defined for action org.actions.DevSortAction and result input

description The requested resource (No result defined for action org.actions.DevSortAction and result input) is not available.

xiao_kan_hong_chen 2011-04-15
  • 打赏
  • 举报
回复
错误信息是你没有定义<result name="input"></result>也就是出错了,你可以设断点调试一下,看有没有执行到该方法。
强长黑粗硬 2011-04-15
  • 打赏
  • 举报
回复
return this.ERROR;


你这个在xml里面没有配置呀
a107494639 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 magong 的回复:]
引用楼主 a107494639 的回复:
No result defined for action org.actions.DevSortAction and result input

该Action只配了success出口,没有配input出口,出错的时候要走input出口
[/Quote]
error出口我已经配置的,在继承的包里有配置一个通用的错误跳转页面
magong 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用楼主 a107494639 的回复:]
No result defined for action org.actions.DevSortAction and result input
[/Quote]
该Action只配了success出口,没有配input出口,出错的时候要走input出口
hzzduoduo 2011-04-15
  • 打赏
  • 举报
回复
好好的试试吧,应该没问题。
hzhj90 2011-04-15
  • 打赏
  • 举报
回复
请用绝对路径,这样最保险。
不用绝对路径,经常会找不到。
a107494639 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 yljames 的回复:]
我还没有出马呢,问题就解决了!!
这种问题,一般先看就如action方法没有,没有进入,明显是路径的问题。如果进入了,就是返回的有问题
[/Quote]

可是现在方法有,却没有进入,而且路径没问题,返回也没有问题。你都没说对,15楼得说对了,我的form表单里的元素写错了个,导致填充失败,直接返回input页。
原来 2011-04-15
  • 打赏
  • 举报
回复
我还没有出马呢,问题就解决了!!
这种问题,一般先看就如action方法没有,没有进入,明显是路径的问题。如果进入了,就是返回的有问题
a107494639 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 chengxx9 的回复:]
引用 10 楼 a107494639 的回复:

发现配置input后,点击提交,没进方法,直接跳到input对应的页面。。。
XML code

<!-- 更新类别信息-->
<action name="updateSortInfo" class="org.actions.DevSortAction" method="updateSortInfo">
<result name="s……
[/Quote]
这个说对了,谢谢大家帮忙。给分喽
a107494639 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 ylz2007 的回复:]
引用 10 楼 a107494639 的回复:

发现配置input后,点击提交,没进方法,直接跳到input对应的页面。。。
XML code

<!-- 更新类别信息-->
<action name="updateSortInfo" class="org.actions.DevSortAction" method="updateSortInfo">
<result name="s……
[/Quote]

后台没异常,什么都没打印
chengxx9 2011-04-15
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 a107494639 的回复:]

发现配置input后,点击提交,没进方法,直接跳到input对应的页面。。。
XML code

<!-- 更新类别信息-->
<action name="updateSortInfo" class="org.actions.DevSortAction" method="updateSortInfo">
<result name="success">/……
[/Quote]


struts2在调用指定方法之前,会执行默认的拦截器帮你把表单中传过来得值设到你action中的属性中,就是这时候出了错,直接返回input,所以没执行你的update方法,请检查你表单中的值是否有错误!
chainhou 2011-04-15
  • 打赏
  • 举报
回复
return的时候吧this去掉!

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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