2019年3月13日

spring mvc@SessionAttributes

摘要: https://www.cnblogs.com/caoyc/p/5635914.html @SessionAttributes原理: 默认情况下,spring mvc将模型中的数据存储到request域中。 当一个请求结束后,数据就失效了。 如果要跨页面使用。那么需要使用session。 而@Ses 阅读全文

posted @ 2019-03-13 17:47 arrows 阅读(216) 评论(0) 推荐(0)

spring mvc-向页面传值-Map、Model和ModelMap

摘要: https://www.cnblogs.com/caoyc/p/5635878.html 除了使用ModelAndView方式外。还可以使用Map,Model和ModelMap来向前台页面传值 使用后面3种方式,都是在方法参数中,指定一个该类型的参数。例如: JSP页面: 结果: 一般使用Map就可 阅读全文

posted @ 2019-03-13 17:01 arrows 阅读(1734) 评论(0) 推荐(0)

spring mvc-使用Servlet原生API作为参数

摘要: https://www.cnblogs.com/caoyc/p/5635701.html 具体看代码: 代码解析: 很明显,要使用Servlet的一些API,只要直接将其作为参数传入即可。你需要request,就传入request,需要session,就传入session。spring mvc支持传 阅读全文

posted @ 2019-03-13 16:51 arrows 阅读(367) 评论(0) 推荐(0)

spring mvc-POJO传参方式

摘要: https://www.cnblogs.com/caoyc/p/5635640.html 有两POJO类: Address.java: User.java: jsp页面: 控制器类: 测试: 1、进入jsp页面: 2、点击提交后,控制台输出: User [username=caoyc, passwo 阅读全文

posted @ 2019-03-13 16:08 arrows 阅读(267) 评论(0) 推荐(0)

spring mvc-@CookieValue注解

摘要: https://www.cnblogs.com/caoyc/p/5635517.html @CookieValue的作用: 用来获取cookie中的值; @CookieValue参数: 1、value:参数名称; 2、required:是否必须; 3、defaultValue:默认值。 @Cooki 阅读全文

posted @ 2019-03-13 15:39 arrows 阅读(401) 评论(0) 推荐(0)

spring mvc-@RequestParam

摘要: https://www.cnblogs.com/caoyc/p/5635427.html 案例说明: 测试1: 当我们请求路径为:http://localhost:8080/springmvc-1/user/add?name=zhangsan&age=18 输出结果:zhangsan,18 测试2: 阅读全文

posted @ 2019-03-13 15:23 arrows 阅读(95) 评论(0) 推荐(0)

spring mvc-REST

摘要: https://www.cnblogs.com/caoyc/p/5635354.html REST风格: /user/1 get请求 获取用户 /user/1 post请求 新增用户 /user/1 put请求 更新用户 /user/1 delete请求 删除用户 在Spring mvc中如何提交p 阅读全文

posted @ 2019-03-13 14:46 arrows 阅读(158) 评论(0) 推荐(0)

spring mvc-@PathVariable注解

摘要: https://www.cnblogs.com/caoyc/p/5635300.html 下面用代码来演示@PathVariable传参方式: @RequestMapping("/user/{id}") public String test(@PathVariable("id") Integer i 阅读全文

posted @ 2019-03-13 14:12 arrows 阅读(1151) 评论(0) 推荐(0)

spring mvc -@RequestMapping注解详解

摘要: https://www.cnblogs.com/caoyc/p/5635173.html @RequestMapping参数说明: value:定义处理方法的请求的URL地址(重点); method:定义处理方法的http method类型,如GEt、POST等。(重点) params:定义请求的U 阅读全文

posted @ 2019-03-13 10:48 arrows 阅读(255) 评论(0) 推荐(0)

spring mvc入门示例

摘要: https://www.cnblogs.com/caoyc/p/5635101.html 1、新建一个Java Web项目 2、导入jar包 【 【在WEB-INF下面建一个hello.jsp页面】 【配置web.xml文件】 【配置spring-mvc.xml文件】 【配置控制器】 】 3、在WE 阅读全文

posted @ 2019-03-13 10:15 arrows 阅读(158) 评论(0) 推荐(0)

spring mvc向前台页面传值-ModelAndView

摘要: https://www.cnblogs.com/caoyc/p/5635782.html ModelAndView 该对象中包含了一个model属性和一个view属性; model:其实是一个ModelMap类型。ModelMap是一个LinkedHashMap的子类。 view:包含了一些视图信息 阅读全文

posted @ 2019-03-13 09:56 arrows 阅读(1414) 评论(0) 推荐(0)

导航