分类: 系统运维
2012-01-20 14:37:31
HTTP Status 404 - No result defined for action com.shengsiyuan.struts2.UserAction and result success
--------------------------------------------------------------------------------
type Status report
message No result defined for action com.shengsiyuan.struts2.UserAction and result success
description The requested resource (No result defined for action com.shengsiyuan.struts2.UserAction and result success) is not available.
原因:在UserAction.java中
public String execute() throws Exception
{
System.out.println("username:"+user.getUsername());
System.out.println("password:"+user.getPassword());
return SUCCESS ;
}
其中SUCCESS没有加引号,改为"SUCCESS"即可。原因: UserAction extends ActionSupport,记得在ActionSupport里有 static final String SUCCESS = “SUCCESS” 。到jar中查找,如图
即是因为找不到jar中部分内容导致。
解决方法:如图导入即可,注意是导入对应文件的src文件夹
错误二:
输入:
a;b
显示:
username:b
password:null
(正确应该是:
username:a
password:b)
原因:
在设置password时,错写成user.setUsername(password) ;即把setPassword错写成setUsername。是因为自己习惯了在写set后直接按快捷键造成。
liumin5942012-08-05 09:41:34
做这个练习的时候我也出现了问题,感觉是UserAction-convertion.properties文件系统根本没有被执行到,浏览器端显示错误The requested resource (No result defined for action com.struts2.UserAction and result input) is not available.,console里出现的错误Error setting expression 'user' with value '[Ljava.lang.String;@1c34817'
ognl.MethodFailedException: Method "setUser" failed for object com.struts2.UserAction@a3b6c [java.lang.NoSuchMethodException: com.struts2.UserAction.setUser([Ljava.lang.String;)]