Spring Security 学习之HTTP表单验证(二)

2014-11-24 01:09:09 · 作者: · 浏览: 15
ivate static final Logger logger = LoggerFactory.getLogger(HomeController.class);

/**
* Simply selects the home view to render by returning its name.
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);

Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

String formattedDate = dateFormat.format(date);

model.addAttribute("serverTime", formattedDate );

return "home";
}

//produces="text/plain" 必须有,否则会有乱码
@RequestMapping(value = "/hello", method = RequestMethod.GET, produces="text/plain")
@ResponseBody
public String hello(){
logger.info("request coming!");
return "Hello Stevex, you are so hard!";
}

}


6. 运行应用进行测试


Spring Security 学习之HTTP表单验证



大功告成!


Spring Web MVC Security 下载地址


具体下载目录在 /2014年资料/2月/28日/Spring Security 学习之HTTP表单验证