摘要:
ModelAndView和Map都是将数据模型放到请求域request中。 (1)若希望在多个请求之间共用某个数据模型属性数据,可以在控制器类上加一个@SessionAttributes。springmvc会将在模型中对应的属性存到HttpSession中。 (2)@SessionAttribute 阅读全文
posted @ 2020-01-10 22:05
西西嘛呦
阅读(244)
评论(0)
推荐(0)
摘要:
SpringmvcTest.java @RequestMapping("/springmvc") @Controller public class SpringmvcTest { private static final String SUCCESS = "success"; @RequestMap 阅读全文
posted @ 2020-01-10 21:29
西西嘛呦
阅读(228)
评论(0)
推荐(0)
摘要:
springmvc提供了以下几种途径来输出模型数据: (1)ModelAndView:处理方法返回值类型为ModelAndView时,方法体即可通过该对象添加模型数据。 (2)Map及Model:入参为org.springframework.ui.Model、org.springframework. 阅读全文
posted @ 2020-01-10 21:21
西西嘛呦
阅读(281)
评论(0)
推荐(0)
摘要:
springmvc可以接受传入的API: HttpServletRequest HttpServletResponse HttpSession java.security.Principal InputStream OutputStream Reader Writer @RequestMapping 阅读全文
posted @ 2020-01-10 20:53
西西嘛呦
阅读(165)
评论(1)
推荐(0)
摘要:
springmvc会按请求参数名和POJO属性名进行匹配,自动为该对象填充属性值,支持级联属性。 User.java package com.gong.springmvc.entities; public class User { private String username; private S 阅读全文
posted @ 2020-01-10 20:45
西西嘛呦
阅读(500)
评论(0)
推荐(0)
摘要:
@RequestMapping(value="/testCookieValue") public String testCookieValue(@CookieValue(value="") String cookie) { System.out.println("cookie="+cookie); 阅读全文
posted @ 2020-01-10 20:28
西西嘛呦
阅读(213)
评论(0)
推荐(0)
摘要:
@RequestMapping("/springmvc") @Controller public class SpringmvcTest { private static final String SUCCESS = "success"; @RequestMapping(value="/testRe 阅读全文
posted @ 2020-01-10 20:23
西西嘛呦
阅读(456)
评论(0)
推荐(0)
摘要:
REST:即资源表现层状态转化。 资源:网络上的一个实体。每种资源对应一个特定的URL。 表现层:把资源具体展现出来的形式,例如文本以txt、html、xml、json或二进制的形式表示。 状态转化:每发出一个请求,就代表了客户端和服务端的一种交互过程,而HTTP请求是无状态协议,即所有的状态都保存 阅读全文
posted @ 2020-01-10 18:52
西西嘛呦
阅读(706)
评论(0)
推荐(0)
摘要:
@PathVariable可以将URL占位符参数绑定到控制器处理方法的形参中。 @RequestMapping("/springmvc") @Controller public class SpringmvcTest { private static final String SUCCESS = " 阅读全文
posted @ 2020-01-10 15:56
西西嘛呦
阅读(737)
评论(0)
推荐(0)
摘要:
Ant风格资源地址支持三种匹配符: ?:匹配文件中的一个字符 *:匹配文件中的任意字符 **:匹配多层路径 ReuqestMapping还支持Ant风格的URL: /user/*/createUser匹配user/aaa/createUser、user/bbb/createUser等URL /use 阅读全文
posted @ 2020-01-10 15:39
西西嘛呦
阅读(202)
评论(0)
推荐(0)
摘要:
@RequestMapping("/springmvc") @Controller public class SpringmvcTest { private static final String SUCCESS = "success"; @RequestMapping(value="testPar 阅读全文
posted @ 2020-01-10 15:32
西西嘛呦
阅读(361)
评论(0)
推荐(0)
摘要:
可以使用method指定请求的方式: package com.gong.springmvc.handlers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotati 阅读全文
posted @ 2020-01-10 15:05
西西嘛呦
阅读(443)
评论(0)
推荐(0)
摘要:
@RequestMapping不仅可以修饰类,也可以修饰方法。 总而言之,用@RequestMapping标识的是请求的URL地址。例如: package com.gong.springmvc.handlers; import org.springframework.stereotype.Contr 阅读全文
posted @ 2020-01-10 14:58
西西嘛呦
阅读(544)
评论(0)
推荐(0)
摘要:
基础目录如下: 步骤: 1.加入jar包到lib目录下。 2.在web.xml中配置DispatcherServlet:web.xml。 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001 阅读全文
posted @ 2020-01-10 14:48
西西嘛呦
阅读(278)
评论(0)
推荐(0)
摘要:
首先来看一下代码: chars = "abcd" tmp = [] for char in chars: tmp.append(ord(char)) print(tmp) 这是一般的写法,将字符串中的每一个字符转换称ASCII码,然后存进一个tmp数组。 利用列表推导的方式: tmp = [ord( 阅读全文
posted @ 2020-01-10 00:06
西西嘛呦
阅读(263)
评论(0)
推荐(0)