5/23 11:54
This commit is contained in:
parent
26db9e99f1
commit
009081ad82
1
.idea/compiler.xml
generated
1
.idea/compiler.xml
generated
@ -11,6 +11,7 @@
|
|||||||
<module name="spring519" />
|
<module name="spring519" />
|
||||||
<module name="spring-mybatis01-522-523" />
|
<module name="spring-mybatis01-522-523" />
|
||||||
<module name="mybatis519" />
|
<module name="mybatis519" />
|
||||||
|
<module name="springmvc-01-523" />
|
||||||
<module name="spring522-annotation" />
|
<module name="spring522-annotation" />
|
||||||
<module name="spring522" />
|
<module name="spring522" />
|
||||||
<module name="mybatis516" />
|
<module name="mybatis516" />
|
||||||
|
2
.idea/encodings.xml
generated
2
.idea/encodings.xml
generated
@ -21,5 +21,7 @@
|
|||||||
<file url="file://$PROJECT_DIR$/spring522-annotation/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/spring522-annotation/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/spring522/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/spring522/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/spring522/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/spring522/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/springmvc-01-523/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/springmvc-01-523/src/main/resources" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -3,6 +3,7 @@
|
|||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$/demo515" />
|
<file type="web" url="file://$PROJECT_DIR$/demo515" />
|
||||||
|
<file type="web" url="file://$PROJECT_DIR$/springmvc-01-523" />
|
||||||
</component>
|
</component>
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
<option name="originalFiles">
|
<option name="originalFiles">
|
||||||
@ -19,6 +20,7 @@
|
|||||||
<option value="$PROJECT_DIR$/spring-mybatis01-522/pom.xml" />
|
<option value="$PROJECT_DIR$/spring-mybatis01-522/pom.xml" />
|
||||||
<option value="$PROJECT_DIR$/printer-522work/pom.xml" />
|
<option value="$PROJECT_DIR$/printer-522work/pom.xml" />
|
||||||
<option value="$PROJECT_DIR$/spring-mybatis01-522-523/pom.xml" />
|
<option value="$PROJECT_DIR$/spring-mybatis01-522-523/pom.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/springmvc-01-523/pom.xml" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
59
springmvc-01-523/pom.xml
Normal file
59
springmvc-01-523/pom.xml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.example</groupId>
|
||||||
|
<artifactId>springmvc-01-523</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-context</artifactId>
|
||||||
|
<version>5.0.3.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<!--springmvc的依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-webmvc</artifactId>
|
||||||
|
<version>5.0.3.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
<version>5.0.3.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>jsp-api</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jstl</groupId>
|
||||||
|
<artifactId>jstl</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.12</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,29 @@
|
|||||||
|
package cn.czyx007.mvc.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import org.springframework.web.servlet.mvc.Controller;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 张宇轩
|
||||||
|
* @createTime : 2023/5/23 - 10:33
|
||||||
|
*/
|
||||||
|
public class MyController implements Controller {
|
||||||
|
@Override
|
||||||
|
public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
|
||||||
|
//接收器群
|
||||||
|
System.out.println("成功接收到请求");
|
||||||
|
//处理请求-不处理-将来要处理
|
||||||
|
System.out.println("处理请求...不处理-将来要处理");
|
||||||
|
//返回响应
|
||||||
|
//ModelAndView封装数据和视图
|
||||||
|
ModelAndView modelAndView = new ModelAndView();
|
||||||
|
//1.封装数据
|
||||||
|
modelAndView.addObject("userName", "abc");
|
||||||
|
//2.封装视图
|
||||||
|
modelAndView.setViewName("WEB-INF/jsp/index.jsp");
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.czyx007.mvc.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 张宇轩
|
||||||
|
* @createTime : 2023/5/23 - 11:40
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
public class UserController {
|
||||||
|
@RequestMapping("/user")
|
||||||
|
public ModelAndView showUser(){
|
||||||
|
//接收器群
|
||||||
|
System.out.println("成功接收到请求");
|
||||||
|
//处理请求-不处理-将来要处理
|
||||||
|
System.out.println("处理请求...不处理-将来要处理");
|
||||||
|
//返回响应
|
||||||
|
//ModelAndView封装数据和视图
|
||||||
|
ModelAndView modelAndView = new ModelAndView();
|
||||||
|
//1.封装数据
|
||||||
|
modelAndView.addObject("userName", "blue");
|
||||||
|
//2.封装视图
|
||||||
|
modelAndView.setViewName("WEB-INF/jsp/index.jsp");
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
}
|
19
springmvc-01-523/src/main/resources/springmvc.xml
Normal file
19
springmvc-01-523/src/main/resources/springmvc.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?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:mvc="http://www.springframework.org/schema/mvc"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
|
||||||
|
http://www.springframework.org/schema/mvc
|
||||||
|
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
|
||||||
|
http://www.springframework.org/schema/context
|
||||||
|
http://www.springframework.org/schema/context/spring-context-4.2.xsd ">
|
||||||
|
|
||||||
|
<!--此处id指要配置拦截的url路径-->
|
||||||
|
<!-- <bean id="/myController" class="cn.czyx007.mvc.controller.MyController"/>-->
|
||||||
|
|
||||||
|
<context:component-scan base-package="cn.czyx007.mvc.*"/>
|
||||||
|
<mvc:annotation-driven/>
|
||||||
|
|
||||||
|
</beans>
|
17
springmvc-01-523/src/main/webapp/WEB-INF/jsp/index.jsp
Normal file
17
springmvc-01-523/src/main/webapp/WEB-INF/jsp/index.jsp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<%--
|
||||||
|
Created by IntelliJ IDEA.
|
||||||
|
User: zyx
|
||||||
|
Date: 2023/5/23
|
||||||
|
Time: 10:38
|
||||||
|
To change this template use File | Settings | File Templates.
|
||||||
|
--%>
|
||||||
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<%--el表达式--%>
|
||||||
|
${userName}
|
||||||
|
</body>
|
||||||
|
</html>
|
26
springmvc-01-523/src/main/webapp/WEB-INF/web.xml
Normal file
26
springmvc-01-523/src/main/webapp/WEB-INF/web.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||||
|
version="4.0">
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>dispatcherServlet</servlet-name>
|
||||||
|
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||||
|
<!--初始化参数,加载springmvc.xml文件-->
|
||||||
|
<init-param>
|
||||||
|
<param-name>contextConfigLocation</param-name>
|
||||||
|
<param-value>classpath:springmvc.xml</param-value>
|
||||||
|
</init-param>
|
||||||
|
<!--加载优先级,数字越小越高-->
|
||||||
|
<load-on-startup>1</load-on-startup>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>dispatcherServlet</servlet-name>
|
||||||
|
<!-- /* 拦截处理所有请求,包括jsp-->
|
||||||
|
<!-- <url-pattern>/*</url-pattern>-->
|
||||||
|
<!-- / 拦截处理所有请求,不包括jsp-->
|
||||||
|
<url-pattern>/</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
</web-app>
|
10
springmvc-01-523/src/main/webapp/index.html
Normal file
10
springmvc-01-523/src/main/webapp/index.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>hello, springmvc!</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user