在spring里,model和form的对应不需要写xml文件,只需要在页面里用form这个taglib就可以了:
email
这里的commandName就是和Controller里相互映射的model的名字(实例名)
path=email指定了对应对象的属性。
Controller里可以这样写:
protected ModelAndView sendInvite(@ModelAttribute(“invite”) Invite invite,
BindingResult result, SessionStatus status, ModelMap model) {}
其中,参数的第一个invite会自动从form里生成一个Invite的实例并设置值,Controller里直接使用这个对象就可以。
而加上@SessionAttributes的话,可以在form里一直显示上次输入的form内容,直到自己调用status.setComplete()为止,这个操作的意思就是一个form相关联的操作已经结束,从session里清空就可以了
Comments Off
Eclipse里提交代码的时候,提示:
org.tigris.subversion.javahl.ClientException: APR does not understand this error code
svn: Commit failed (details follow):
svn: Cannot accept non-LF line endings in ‘svn:log’ property
comment写了2行而已,查了下,网上有人说每行最后以空格结尾就行了,我试了下还是不行。
不要comment,提交成功。。。奇怪。
Comments Off
在java里可以用:request.setCharacterEncoding(“UTF-8″);
在Spring的Controller类里个别设置太麻烦,可以用filter
- <filter-name>Spring character encoding filter</filter-name>
- <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
- <init-param>
- <param-name>encoding</param-name>
- <param-value>utf-8</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>Spring character encoding filter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
Comments Off