
_____3.3 springmvc
sunpy 孙培煜
万物之中,希望至美;至美之物,永不凋零。
展开
-
springmvc中@RequestParam和@PathVariable的区别
@RequestParam:这个注解的作用是对于携带参数的请求,而自定义的方法testRequestMapping通过@RequestParam注解来获得静态的URL请求携带的参数。至于@PathVariable直接就把url上传过来的值直接就给它绑定到方法上了。所以就会发现,它的请求参数为空。而RequestParam请求参数不为空。可想而知,它们url的写法肯定也是不同的。@R原创 2016-07-28 21:51:38 · 704 阅读 · 0 评论 -
springmvc之数据转换
1.为什么使用springmvc的数据转换首先由于java提供的PropertyEditor的核心功能是将一个字符串转为一个java对象,但是PropertyEditor只能用于字符串到java对象的转换,不适用于任意两个java类型之间的转换。对源对象及目标对象所在的上下文信息不敏感,在类型转换时不能利用这些上下文信息实施高级的转换逻辑。spring不仅对PropertyEditor原创 2017-07-31 20:28:28 · 419 阅读 · 0 评论 -
springmvc之处理模型数据
1.springmvc为什么要处理模型数据当我们采用映射路径映射到方法处理完数据时,需要将数据显示在页面上。然而springmvc框架提供可以将模型数据暴露给视图的解决方案。2.springmvc提供了哪些处理模型数据的方案① ModelAndView :当处理方法返回值类型为ModelAndView时,方法体即可通过该对象添加模型数据。② @ModelAttribute注解 :原创 2017-07-31 10:08:47 · 444 阅读 · 0 评论 -
springmvc之返回json
1.搭建环境: junit junit 4.11 test commons-logging commons-logging 1.1.3 org.springframework spring-core 4.0.5.RELEASE or原创 2017-04-19 21:32:15 · 299 阅读 · 0 评论 -
springmvc之文件上传MultipartResolver
1.介绍springmvc提供了MultipartResolver来实现文件的上传。其实现类为CommonsMultipartResolver。springmvc默认是没有配置MultipartResolver的。如果想要使用那么就需要在springmvc的上下文配置文件里配置。2.实例搭建环境: junit junit 4.11原创 2017-04-20 20:52:40 · 384 阅读 · 0 评论 -
springmvc之HttpMessageConverter
1.pom.xml: junit junit 4.11 test commons-logging commons-logging 1.1.3 org.springframework spring-core 4.0.5.RELEASE原创 2017-04-20 20:23:50 · 334 阅读 · 0 评论 -
springmvc之@InitBinder注解
1.使用场景当我们在页面传递的pojo中,有不需要的参数,则通过WebDataBinder来设置不传的参数。2.搭建环境<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://原创 2017-04-16 22:42:16 · 574 阅读 · 0 评论 -
springmvc之自定义类型转换器ConversionServiceFactoryBean
1.搭建环境pom.xml:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org原创 2017-04-16 22:06:57 · 9075 阅读 · 1 评论 -
springmvc之自定义视图BeanNameViewResolver
1.搭建环境:pom.xml:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.or原创 2017-04-16 12:29:08 · 517 阅读 · 0 评论 -
springmvc之<mvc:view-controller/>标签使用
1.配置环境,pom.xml:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.or原创 2017-04-16 11:18:50 · 2629 阅读 · 0 评论 -
springmvc之jstlView使用
1.引入jar包:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/mave原创 2017-04-15 22:50:52 · 7555 阅读 · 1 评论 -
springmvc之JSR303数据校验
1.搭建环境 junit junit 4.11 test commons-logging commons-logging 1.1.3 org.springframework spring-core 4.0.5.RELEASE org原创 2017-04-19 20:09:10 · 858 阅读 · 0 评论 -
springmvc之数据的格式化
1.搭建环境 junit junit 4.11 test commons-logging commons-logging 1.1.3 org.springframework spring-core 4.0.5.RELEASE org原创 2017-04-17 21:50:08 · 448 阅读 · 0 评论 -
springmvc之注解开发
1.注解开发的准备工作(1)导包:(2)为了加载spring的配置文件方式1:使用contextConfigLocation来加载spring配置文件: springmvc-1 springDispatcherServlet org.springframework.web.servlet.DispatcherServlet原创 2017-02-26 21:59:40 · 558 阅读 · 0 评论 -
springmvc之Restful
1.什么是RestfulRest的意思就是表述性状态转移。理解就是表示被为操作资源。其实也是一种基于http结构的东西。然后应该知道这不是一种定义的规范也不是什么标准。就是一种用来表示数据以及操作服务器中资源的方法。但是Rest web的服务却又依赖于Http协议。2.Restful风格的增删改查策略(1)GET方法通常用来获取某一资源或者资源集合。(2)POST方法用于创建。原创 2017-03-04 18:25:44 · 982 阅读 · 0 评论 -
springmvc传值方式
请求路径上有个id的变量值,可以通过@PathVariable来获取 @RequestMapping(value = "/page/{id}", method = RequestMethod.GET) @RequestParam用来获得静态的URL请求入参 spring注解时action里用到。简介:handler method 参数绑定常用的注解,我们根据他们处理转载 2017-12-01 10:41:37 · 422 阅读 · 0 评论