应用型项目部分总结

1.将后台所有的页面会传入控制层的字段 封装成一个类 所有的页面请求到控制层 可以只用定义一个类就可以全部接收表单传过来值

@RequestMapping(value = "currencyGoldTotal", method = { RequestMethod.GET, RequestMethod.POST })
public String currencyGoldTotalListPage(@ModelAttribute("example") EventLog example, ModelMap mm,

2.传入mybatis的xml文件的所有的字段 也可以封装成一个类

List<LogAccount> getRolePayTotalPrice(@Param("example")BaseEvent el);

3.可以在所有控制层的类都继承一个父类 父类实现了控制层的类常用的代码

public class CurrencyCt extends BaseCtrl

4.一般会对页面传过来的值封装个方法 方法对传过来的是 日期类型 整型类型 字符串类型 进行封装 进行特殊的处理

protected String reqString(String paramKey,HttpServletRequest request) {
if (request.getAttribute(paramKey) != null) {
return (String)request.getAttribute(paramKey);
}
if (request.getParameter(paramKey) != null) {
return (String)request.getParameter(paramKey);
}
return null;
}
protected int reqInteger(String paramKey,HttpServletRequest request) {
String valStr = reqString(paramKey,request);
if(valStr == null || "".equals(valStr)){
return 0;
}else{
return Integer.valueOf(valStr);
}
}

 


posted @ 2017-11-20 13:55  1master5  阅读(249)  评论(0编辑  收藏  举报