![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
三阶段.springMvc
烦到困
学习的痛苦......是终生的
展开
-
SpringMvc配置
添加jar包配置web.xml文件spring.xml文件配置视图解析器加载配置文件,获得关联添加jar包<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --><dependency> <groupId>javax.servlet&a原创 2018-10-13 16:14:16 · 83 阅读 · 0 评论 -
拦截器
创建拦截器的类实现接口配置Spring.xml文件拦截器,只能拦截请求,不拦截页面测试index.jsp:<a href="getjson">getjson对象测试</a><a href="getjson1">getjson1集合测试</a&am原创 2018-10-15 22:18:08 · 74 阅读 · 0 评论 -
RESTful配置以及测试
RESTful介绍REST:即Representational State Transfer ,(资源)表现层状态转化,是目前最流行的一种互联网软件架构。具体说,就是HTTP协议里面,四个表示操作方式的动词:GET POST PUT DELETE它们分别代表着四种基本操作:GET用来获取资源POST用来创建新资源PUT用来更新资源DELETE用来删除资源示例:/order...原创 2018-10-14 23:09:16 · 1013 阅读 · 0 评论 -
处理静态资源
修改Spring MVC对应配置文件,添加mvc命名空间和约束添加处理标签命名空间添加 xmlns:mvc="http://www.springframework.org/schema/mvc" http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spr...原创 2018-10-14 21:37:58 · 143 阅读 · 0 评论 -
ant风格的路径
ant风格资源地址支持3种匹配符:?:匹配文件名中的一个字符,例如:/springmvc/?abc/index.jsp*:匹配文件名中的任意多个字符**:匹配多层路径@RequestMapping(value = "user/**/getb1") public String b1(){ System.out.println("b1------------");...原创 2018-10-14 21:34:34 · 1051 阅读 · 0 评论 -
param通过表达式精准映射请求
@RequestMapping中的属性:value,method, params参数param:表示请求必须包含名为param的请求参数,实例:params={“a1”,“a2”},请求要两个参数都有!param:表示请求中不能包含名为param的参数,实例:params={"!a1",“a2”}param != value:表示请求中包含param的请求参数,但是值不能为value,实例...原创 2018-10-14 21:29:34 · 275 阅读 · 0 评论 -
cookie注解和请求头注解
使用cookie注解得到cookie的值添加cookie请求头注解@RequestHeader(“Accept”) @RequestMapping("addcookie") public String add(@RequestHeader("Accept") String accept, HttpServletResponse response){ System.ou...原创 2018-10-14 21:27:17 · 651 阅读 · 0 评论 -
跳转出现异常时,跳转到异常处理页面
两种方式解决异常跳转指定页面web.xml文件: <error-page> <error-code>500</error-code> <location>/exception500.jsp</location> </error-page>添加注解@ExceptionHandler@Excepti...原创 2018-10-14 21:19:33 · 4003 阅读 · 0 评论 -
springMvc的重定向跳转
return “redirect:abc.jsp”;return "redirect:abc"会解读为请求原创 2018-10-14 21:13:43 · 291 阅读 · 0 评论 -
@SessionAttributes注解和ModelMap一起使用时,数据作用域
HttpServletRequest request, HttpSession session, ModelMap map 请求测试不绑定@SessionAttributes注解test.java:类上添加注解@Controller @RequestMapping("test7") public String test7(HttpServletRequest request, Ht...原创 2018-10-14 17:22:30 · 1032 阅读 · 0 评论 -
SpringMVC获取页面提交的参数以及返回提交信息测试
无参数请求测试index.jsp<a href="/test">无参测试</a>text.java添加注解@Controller@Controllerpublic class TextController { private HttpSession session; private ModelMap map; private HttpS...原创 2018-10-13 16:58:23 · 435 阅读 · 0 评论 -
上传和下载文件测试
上传文件上传文件时,存放上传文件的文件夹不能为空,因为编译时,空的文件夹在target目录下是不存在的配置Spring.xml &amp;lt;!--文件上传 id的名字不能随便起--&amp;gt; &amp;lt;bean id=&quot;multipartResolver&quot; class=&quot;org.springframework.web.multipart.com原创 2018-10-15 22:32:26 · 838 阅读 · 0 评论