No result defined for action com.niit.ssh2.action.BookAction and result success

来源:互联网 发布:js animate transform 编辑:程序博客网 时间:2024/05/16 16:17
先前是因为

struts2异常java.lang.NoSuchMethodException: com.struts.action.UserAction.create()这个异常造成的。可是我的方法什么的都有。只是先前把acation的类名写错了。写成另一个action类了。改过以后还出这个错。重启服务器。过了好一会才反应过来。是我电脑本身的原因吧。


在后面又出现一个错误。No result defined for action com.niit.ssh2.action.BookAction and result succ
这是我的控制台信息:写给大家看的项目管理书-第2版***Gregory M.Horine
2013-06-20 23:02:13,771 ERROR [org.apache.struts2.dispatcher.Dispatcher] - Could not find action or result
/ssh2_wl/findBookById?id=3
No result defined for action com.niit.ssh2.action.BookAction and result success


我在网上搜了好久,那些方法都对我没用。我后面想想,我控制台已经进入哪个action方法了。这是控制台输出的信息。已经能找到了。我又在struts里配置了一个error的返回。这是action的方法
public String findBookById() throws Exception {
book = bookService.findBookById(id);
System.out.println(book.getTitle()+"***"+book.getAuthor());
if(book!=null){
return SUCCESS;
}else{
return ERROR;
}

这是struts的配置:
<action name="findBookById" class="com.niit.ssh2.action.BookAction"                            method="findBookById">
<result name="SUCCESS">/ProductBase.jsp</result>
<result name="ERROR">/ProductBase.jsp</result>

</action>这样的配置还出错。
换成这样才对了:
<action name="findBookById" class="com.niit.ssh2.action.BookAction" method="findBookById">
<result>/ProductBase.jsp</result>
<result name="ERROR">/ProductBase.jsp</result>
</action>
这样也是对的:
<action name="findBookById" class="com.niit.ssh2.action.BookAction" method="findBookById">
<result>/ProductBase.jsp</result>
</action>

不知道什么原因。贴上来给大家参考一下。
原创粉丝点击