MDA/MDD/TDD/DDD/DDDDDDD
posts - 536, comments - 111, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

spring mvc笔记

Posted on 2009-01-08 09:31 leekiang 阅读(294) 评论(0)  编辑  收藏 所属分类: spring
1,<spring:bind>是spring2.0以前的写法。
2,public ModelAndView login(HttpServletRequest request,
            HttpServletResponse response,HttpSession session,User user)
  public ModelAndView login(HttpServletRequest request,
            HttpServletResponse response,User user)
MultiActionController自动把最后一个参数当作Command对象。
也可以覆盖protected Object newCommandObject(Class clazz)方法,但这样每个 Controller的Command对象就是同一个iele,
同时要改为
public ModelAndView login(HttpServletRequest request,
            HttpServletResponse response,Object command)再对command造型
            
3,重定向写法
return new ModelAndView("redirect:/system/user.do?do=addUserForm");

4,有2个JsonView的,或者更适合Ajax,当然自己写一个JsonView都很简单
1) json-lib-ext-spring
http://sourceforge.net/projects/json-lib/files/
2) spring json view
http://spring-json.sourceforge.net/download.html
http://article.yeeyan.org/view/jdonee/10145

5, 绑定的基本写法
ServletRequestDataBinder binder = new ServletRequestDataBinder(obj);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        binder.registerCustomEditor(Date.class, new CustomDateEditor(
                dateFormat, true));
        binder.setDisallowedFields(new String[]{"endtime"});
        binder.bind(request);

只有注册用户登录后才能发表评论。


网站导航: