SpringMVC
星夜孤帆
人之有吾,当应披荆棘,斩鬼熊,成就一番大事
展开
-
Spring MVC 数据处理与乱码问题
一、数据处理1.1 处理提交数据1.1.1 提交的域名称和处理方法的参数名一致提交数据:http://localhost:8080/hello?name=test处理方法:@RequestMapping("/hello")public String hello(String name){ System.out.println(name); return "hello";}后台输出test1.1.2 提交的域名称和处理方法的参数名不一致提交数据:http.原创 2020-12-05 15:13:56 · 745 阅读 · 2 评论 -
Spring MVC 转发和重定向
一、结果跳转方式1.1 ModelAndView设置ModelAndView对象,根据view的名称,和视图解析器跳到指定的页面。页面:{视图解析器前缀} + viewName + {视图解析器后缀}<!-- 视图解析器 --><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="internalResourceViewResolver">原创 2020-12-05 02:58:01 · 429 阅读 · 0 评论 -
Spring MVC Controller和Restful
一、控制器Controller 控制器复杂提供访问应用程序的行为,通常通过接口定义或注解定义两种方法实现。 控制器负责解析用户的请求并将其转换为一个模型。 在Spring MVC中一个控制器类可以包含多个方法 在Spring MVC中,对于Controller的配置方式有很多种 1.1 实现Controller接口Controller是一个接口,在org.springframework.web.servlet.mvc包下,接口中只有一个方法;//实现该接口的原创 2020-12-04 20:09:30 · 370 阅读 · 0 评论 -
Idea搭建Spring MVC工程
一、什么是MVC1.1 MVC MVC是模型(Model)、视图(View)、控制器(Controller)的简写,是一种软件设计规范。 是将业务逻辑、数据、显示分离的方法来组织代码。 MVC主要作用是降低了视图与业务逻辑间的双向偶合。 MVC不是一种设计模式,MVC是一种架构模式。当然不同的MVC存在差异。 Model(模型):数据模型,提供要展示的数据,因此包含数据和行为,可以认为是领域模型或JavaBean组件(包含数据和行为),不过现在一般都分离开来:Va原创 2020-12-04 15:52:12 · 492 阅读 · 1 评论 -
IDEA搭建Servlet工程
一、搭建项目工程二、整合tomcat2.1 下载tomcat百度云下载:http://pan.baidu.com/s/1c18VOwo下载完之后解压,如下2.2 配置tomcatidea启动如果出现乱码,在这里可以配置为相应编码2.3启动tomcat在bin目录下启动和停止tomcat启动之后,访问http://localhost:8080/如果加载出Apache Tomcat的页面,即说明启动成功。三、Idea整合tomc..原创 2020-12-03 19:43:00 · 310 阅读 · 0 评论 -
SpringMVC基础-13-拦截器interceptor
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/xsd/...原创 2019-04-22 10:13:37 · 119 阅读 · 0 评论 -
SpringMVC基础-14-拦截器使用案例-权限控制
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/xsd/...原创 2019-04-22 10:32:54 · 139 阅读 · 0 评论 -
SpringMVC基础-15-使用SpringMVC实现简单的增删改查
User.javapackage com.monkey1024.bean;import java.time.LocalDate;import org.springframework.format.annotation.DateTimeFormat;/* * 用户 */public class User { private String name; private ...原创 2019-04-22 12:00:10 · 674 阅读 · 0 评论 -
Maven中引入fast-json
在项目中使用到json,由于数据的频繁转化,考虑到系统的性能使用了阿里巴巴封装的fastjson。项目的环境配置jdk1.7tomcat8maven3.39在pom中引入的依赖<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson<...原创 2019-04-22 15:00:45 · 26250 阅读 · 0 评论 -
SpringMVC基础-16-基于SpringMVC的restful架构风格
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/xsd/...原创 2019-04-22 16:08:17 · 155 阅读 · 0 评论 -
SpringMVC基础-12-文件上传
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/xsd/...原创 2019-04-22 01:03:00 · 99 阅读 · 0 评论 -
SpringMVC基础-11-数据校验
springmvc.xml<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="...原创 2019-04-21 22:41:31 · 111 阅读 · 0 评论 -
SpringMVC基础-02-使用注解
配置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/...原创 2019-04-20 18:44:22 · 132 阅读 · 0 评论 -
SpringMVC基础-03-RequestMapping常用属性
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/x...原创 2019-04-20 19:42:34 · 175 阅读 · 0 评论 -
SpringMVC基础-04-单个接受表单提交数据
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/xsd/...原创 2019-04-20 21:09:48 · 99 阅读 · 0 评论 -
SpringMVC基础-05-使用对象接受表单参数
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/x...原创 2019-04-21 13:01:00 · 448 阅读 · 0 评论 -
SpringMVC基础-06-路径变量PathVariable
PathController.javapackage com.monkey1024.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web....原创 2019-04-21 13:12:11 · 388 阅读 · 0 评论 -
SpringMVC基础-07-Controller中方法的返回值
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/xsd/...原创 2019-04-21 15:12:03 · 141 阅读 · 0 评论 -
SpringMVC基础-08-转发与重定向
School.javapackage com.monkey1024.bean;/* * 学校 */public class School { public String getSchoolName() { return schoolName; } public void setSchoolName(String schoolName) { this.schoolNam...原创 2019-04-21 16:44:23 · 136 阅读 · 0 评论 -
SpringMVC基础-09-异常处理的三种方式
spring.xml<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http...原创 2019-04-21 20:22:36 · 207 阅读 · 0 评论 -
SpringMVC基础-10-类型转换器
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/xsd/...原创 2019-04-21 21:51:13 · 101 阅读 · 0 评论 -
SpringMVC基础-01-SpirngMVC简单流程
配置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/...原创 2019-04-20 18:12:27 · 108 阅读 · 0 评论