如何更改struts中错误默认返回input InputConfig内methodName跟resultName的使用方法
来源:互联网 发布:java上传图片到tomcat 编辑:程序博客网 时间:2024/05/22 06:11
Struts2 API中InputConfig内methodName跟resultName的使用方法
关于Struts2 API中InputConfig内methodName和resultName的使用方法
对于@InputConfig中methodName和resultName的区别很是迷惑.最后在API中找到答案了,通过做实验终于了之.
(1).Marks a action method that if it's not validated by Validationlnterceptor then execute input method or input result.
Annotation usage:The InputConfig annotation can be applied at method level.
Annotation parameters:
Parameter Required Default Notes
methodName no (2).execute this method if specific
resultName no (3).return this result if methodName not specific
(1).当验证方法没有通过时,改变默认返回的input视图
(2).methodName=====>执行指定方法
(3).resultName=====>返回result如果methodName没有指定
Eg:
@InputConfig(methodName="Tqtest",resultName="resultTest")
@InputConfig(methodName="Tqtest",resultName="resultTest") 的作用是改变默认返回的input视图 API中可查
resultName只有在methodName没写如@InputConfig(resultName="resultTest") 时才起做用
通过指定methodName即可以修改input的默认返回为自己指定的:
例如:如果访问toResourceSave()方法时没有通过validate验证而报错,默认情况是不会跳转到save视图而是input视图。但是我们可以在方法头部加入注解@InputConfig(methodName="saveInputReturn")指定如果没有通过validate验证通过则返回saveInputReturn的返回值视图save1.
/**
* 跳转到资源添加、修改页面
* @return
*/
@InputConfig(methodName="saveInputReturn")
public String toResourceSave(){
//获取该分类下资源概览字段
List<UlibResourceColumn> listcolumns=ucolumnService.findUlibResourceColumnByProperty("typeid",typeid);
Map<String,String> columnsmap=new HashMap<String,String>();
for(UlibResourceColumn c:listcolumns){
columnsmap.put(c.getCode(),c.getShowname().equals("")?c.getDefaultname():c.getShowname());
}
if(uresource.getId()==null || uresource.getId().equals("")){//添加资源
getRequest().setAttribute("isupdate", "0");
}else{//浏览、修改资源
uresource=this.uresourceService.getUresourceById(uresource.getId());
getRequest().setAttribute("isupdate", "1");
if("view".equals(getRequest().getParameter("opt"))){
getRequest().setAttribute("isview", "1");
}
}
this.getRequest().getSession().setAttribute("showcolumns", columnsmap);
return "save";
}
public String saveInputReturn(){
return "save1";
}
- 如何更改struts中错误默认返回input InputConfig内methodName跟resultName的使用方法
- 关于struts2 API 中InputConfig 内 methodName 和resultName的使用方法
- 关于struts2 API 中InputConfig 内 methodName 和resultName的使用方法
- 更改input等的默认样式
- cocos2dx vc跟Eclipse中更改默认的physics为box2d
- 如何更改默认的Client
- WSAD:5版本中如何更改默认的工作区
- Myeclipse中如何更改jsp默认的打开方式
- Myeclipse中如何更改jsp默认的打开方式
- Myeclipse中如何更改jsp默认的打开方式
- Myeclipse中如何更改jsp默认的打开方式
- OAF中如何更改query的默认查询
- Myeclipse中如何更改jsp默认的打开方式
- Myeclipse中如何更改jsp默认的打开…
- Myeclipse中如何更改jsp默认的打开方式
- Myeclipse中如何更改jsp默认的打开方式
- Myeclipse中如何更改jsp默认的打开方式
- oracle中如何更改order by的默认排序?
- nginx访问php页面出现No input file specified.
- 开启apache的url rewrite模块
- p,&p,*p的区别
- 【算法题】二叉树的前序遍历(递归和非递归算法分析)
- jquery图片滚动效果插件SuperSlide1.2
- 如何更改struts中错误默认返回input InputConfig内methodName跟resultName的使用方法
- javaEE--ibatis--Sping+flex4 调用存储过程返回List结果集
- 监听输入框值的即时变化onpropertychange、oninput
- AudioManager学习
- 日语的商品购物与消费
- ABAddressBook & AddressBook UI 文件介绍(IOS开发)
- VC内存泄露检测之运行时库(CRT)
- WSA_FLAG_OVERLAPPED Is Needed for Non-Blocking Sockets
- 娱乐,C语言模拟C++虚函数多态性