随笔分类 -  springMVC

摘要:使用场景例子: 用户登陆系统一般会往Session里放置一个VO对象,然后在controller里会来获取用户的userId等信息。 之前的写法是:@SessionAttributes配合@ModelAttribute来进行参数值的注入,但这样需要写2个注解,其中SessionAttributes加 阅读全文
posted @ 2017-01-13 11:57 自行车上的程序员 阅读(4363) 评论(0) 推荐(0) 编辑
摘要:@ControllerAdvice是Spring 3.2新增的注解,主要是用来Controller的一些公共的需求的低侵入性增强提供辅助,作用于@RequestMapping标注的方法上。 ControllerAdvice的定义如下: 和此注解配合使用的其他注解有: 下面给一个例子: 阅读全文
posted @ 2016-12-09 10:00 自行车上的程序员 阅读(11692) 评论(1) 推荐(0) 编辑
摘要:HTML: 常见的帮助类有2个:一个是spring的HtmlUtils,另外一个是apache.commons下的StringEscapeUtils JavaScript: 常见的帮助类有2个:一个是spring的JavaScriptUtils,另外一个是apache.commons下的String 阅读全文
posted @ 2016-07-13 15:48 自行车上的程序员 阅读(38393) 评论(0) 推荐(1) 编辑
摘要:在一个大网站里,有很多子域名,也就是有很多子系统,这些子系统由不同的团队负责,对整个网站的风格的风格至少得要是一致的(最基本的页头、页尾必须一致),这个时候得提供一份统一的页头、页尾以及公共的JS、css等内容,但如果是直接给源代码(ftl/js/css)的形式,对于后期的升级维护必然增加不必要的麻 阅读全文
posted @ 2016-05-09 17:41 自行车上的程序员 阅读(2882) 评论(0) 推荐(0) 编辑
摘要:CSRF的概念可以参考:http://netsecurity.51cto.com/art/200812/102951.htm 本文介绍的是基于spring拦截器的Spring MVC实现 首先配置拦截器: <mvc:interceptors> <mvc:interceptor> <!-- 匹配的是u 阅读全文
posted @ 2015-10-28 16:55 自行车上的程序员 阅读(1897) 评论(0) 推荐(0) 编辑
摘要:JSONP这个东东是啥我就不写了,直接贴实现的代码 JAVA代码: out.flush(); out.close(); 之前使用直接返回String出现字符被截取掉了(原因未知),后改成使用PrintWriter对象直接输出。 JS代码: Jquery文档描述: 如果不用上门的JSONP代码调用,而 阅读全文
posted @ 2015-09-21 18:18 自行车上的程序员 阅读(4092) 评论(0) 推荐(0) 编辑
摘要:下载//下载 @RequestMapping(value="/download") public ResponseEntity download() throws IOException{ String fileName = "test.txt"; File ... 阅读全文
posted @ 2014-05-14 12:31 自行车上的程序员 阅读(2347) 评论(0) 推荐(0) 编辑
摘要:参考:http://starscream.iteye.com/blog/1075855 阅读全文
posted @ 2014-05-14 10:43 自行车上的程序员 阅读(575) 评论(0) 推荐(0) 编辑
摘要:参考:http://starscream.iteye.com/blog/1075854 阅读全文
posted @ 2014-05-14 10:36 自行车上的程序员 阅读(286) 评论(0) 推荐(0) 编辑
摘要:参考:http://starscream.iteye.com/blog/1072180 阅读全文
posted @ 2014-05-14 10:33 自行车上的程序员 阅读(337) 评论(0) 推荐(0) 编辑
摘要:输入前台代码: var cfg = { type: 'POST', data: JSON.stringify({userName:'winzip',password:'password',mobileNO:'13818881888'}), ... 阅读全文
posted @ 2014-05-14 10:19 自行车上的程序员 阅读(1885) 评论(0) 推荐(0) 编辑
摘要:1、全局处理 /error 500 org.springframework.web.servlet.handler.SimpleMappingEx... 阅读全文
posted @ 2014-05-13 23:16 自行车上的程序员 阅读(337) 评论(0) 推荐(0) 编辑
摘要:@InitBinder 在controller中注册一个customer protperty editor以解析request中的参数并通过date bind机制与handler method中的参数做绑定。@InitBinderpublic void initBinder(WebDataBinde... 阅读全文
posted @ 2014-05-13 23:13 自行车上的程序员 阅读(369) 评论(0) 推荐(0) 编辑
摘要:@RequestMapping的可选参数 value:表示需要匹配的url的格式。 method:表示所需处理请求的http 协议(如get,post,put,delete等),可选值为RequestMethod这个enum的值。 params:格式为”paramname=paramvalue” 或... 阅读全文
posted @ 2014-05-13 22:47 自行车上的程序员 阅读(8906) 评论(0) 推荐(0) 编辑
摘要:MVC的拦截器 经本人在Spring mvc中对方案1和方案2的测试表明,并没有拦截静态资源,所以可以放心使用方案1和方案2,方案3可以放弃,并且可以放心使用<mvc:annotation-driven />注解。 方案一,(近似)总拦截器,拦截所有url 为什么叫“近似”,前面说了,Spring没 阅读全文
posted @ 2014-05-13 16:33 自行车上的程序员 阅读(167977) 评论(1) 推荐(0) 编辑
摘要:在spring mvc3.2及以上版本增加了对请求的异步处理,是在servlet3的基础上进行封装的。1、修改web.xml...1.1、声明version="3.0",声明web-app_3_0.xsd1.2、为servlet或者filter设置启用异步支持:true,修改WEB应用的web.xm... 阅读全文
posted @ 2014-05-13 11:27 自行车上的程序员 阅读(58420) 评论(2) 推荐(1) 编辑
摘要:一、在SringMVC中使用 使用注解 1、准备校验时使用的JAR validation-api-1.0.0.GA.jar:JDK的接口; hibernate-validator-4.2.0.Final.jar是对上述接口的实现; log4j、slf4j、slf4j-log4j 2、编写需要校验的b 阅读全文
posted @ 2014-05-13 10:35 自行车上的程序员 阅读(102973) 评论(4) 推荐(11) 编辑
摘要:1、新建web项目,并在web.xml加入spring mvc的servlet springMVC org.springframework.web.servlet.DispatcherServlet contextConfigLocation ... 阅读全文
posted @ 2014-05-13 10:23 自行车上的程序员 阅读(27906) 评论(0) 推荐(1) 编辑
摘要:http://elf8848.iteye.com/blog/875830 可以做入门参考,英语好可以阅读spring的spring-framework-reference更多学习bloghttp://starscream.iteye.com/blog/1098880http://downpour.i... 阅读全文
posted @ 2013-07-04 16:42 自行车上的程序员 阅读(403) 评论(0) 推荐(0) 编辑