Struts2 异常:no result defined for action result input
2014-05-05 09:00
302 查看
在开发中总遇到这个问题,no result defined for action result input,这个问题好像在strtus2.1以上版本才出现
原因:Action中的属性值为空的时候,Struts2的默认拦截器会报错,但是又找不到input的Result,不能够把错误返回,所以报这种错误。
解决方法:
1.在页面中给空值赋默认值。
2.重新定义一个Action,去掉空值的成员变量。
3.添加input的Result,并在这个页面给出提示
--------------------------------------------------------------------------
当你在用struts2开发时,如果,从页面跳入action时,页面报No result defined for action and result时,大部分的原因有以下几种:
1、validate方法没有通过;
2、页面元素中有重命名时,但后台action类的对应的接收此同名参数的是变量而没有写成数组
--------------------------------------------------------------------------
要检查这种错误时,可以
1,在后台action类中重写ActionSupport中的
void addActionError(String anErrorMessage)
void addActionMessage(String aMessage)
void addFieldError(String fieldName, String errorMessage)
这三个方法,在并在其实现代码中设置断点,监控传入的参数,并可获知页面的相关报错具体原因.
2,在页面中加入以下标签,将错误显示出来 :
< div style =”color:red” >
< s:fielderror />
</ div >
--------------------------------------------------------------------------
public void addActionError(String anErrorMessage){
String s=anErrorMessage;
System.out.println(s);
}
public void addActionMessage(String aMessage){
String s=aMessage;
System.out.println(s);
}
public void addFieldError(String fieldName, String errorMessage){
String s=errorMessage;
String f=fieldName;
System.out.println(s);
System.out.println(f);
}
原因:Action中的属性值为空的时候,Struts2的默认拦截器会报错,但是又找不到input的Result,不能够把错误返回,所以报这种错误。
解决方法:
1.在页面中给空值赋默认值。
2.重新定义一个Action,去掉空值的成员变量。
3.添加input的Result,并在这个页面给出提示
--------------------------------------------------------------------------
当你在用struts2开发时,如果,从页面跳入action时,页面报No result defined for action and result时,大部分的原因有以下几种:
1、validate方法没有通过;
2、页面元素中有重命名时,但后台action类的对应的接收此同名参数的是变量而没有写成数组
--------------------------------------------------------------------------
要检查这种错误时,可以
1,在后台action类中重写ActionSupport中的
void addActionError(String anErrorMessage)
void addActionMessage(String aMessage)
void addFieldError(String fieldName, String errorMessage)
这三个方法,在并在其实现代码中设置断点,监控传入的参数,并可获知页面的相关报错具体原因.
2,在页面中加入以下标签,将错误显示出来 :
< div style =”color:red” >
< s:fielderror />
</ div >
--------------------------------------------------------------------------
public void addActionError(String anErrorMessage){
String s=anErrorMessage;
System.out.println(s);
}
public void addActionMessage(String aMessage){
String s=aMessage;
System.out.println(s);
}
public void addFieldError(String fieldName, String errorMessage){
String s=errorMessage;
String f=fieldName;
System.out.println(s);
System.out.println(f);
}
相关文章推荐
- HTTP Status 404 - No result defined for action EmployeeAction and result input - struts2类似异常解决及原因剖析
- struts2的一个异常:No result defined for action XXX and result input
- struts2 拦截器报错:No result defined for action xxx.action and result input
- 关于struts2上传文件报错“No result defined for action and result input”
- struts2的No result defined for action 。。。。and result input 问题
- struts2 No result defined for action.....and result input
- 关于struts2中No result defined for action这个异常的解决思路
- struts2的那些事儿--No result defined for action.....and result input
- Struts2——No result defined for action and result input - action错误(今天也遇到,没见过很难找)
- Struts2:(No result defined for action ** and result input) is not available.
- Struts2-No result defined for action and result input
- HTTP Status 404 - No result defined for action EmployeeAction and result input - action类似异常解决及原因剖析
- [SSH]No result defined for action and result input 和 Struts2中关于值跳转input,而不执行action的问题
- struts2 上传文件 HTTP Status 404 - No result defined for action.....and result input
- struts2 no result defined for action xxxx and result input
- struts2:No result defined for action com.jcyj.action.fitting.FittingsAction and result input
- Struts2 项目报错 No result defined for action com.xxx.xxAction and result input
- Struts2问题,已解决No result defined for action and result input
- Struts2常见错误-No result defined for action XXX and result input
- struts2的那些事儿--No result defined for action.....and result input