5/24 16:40
This commit is contained in:
parent
3e2ee2669b
commit
6305cdf583
15
.idea/compiler.xml
generated
15
.idea/compiler.xml
generated
@ -9,16 +9,23 @@
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="printer-522work" />
|
||||
<module name="spring519" />
|
||||
<module name="spring-mybatis01-522-523" />
|
||||
<module name="mybatis519" />
|
||||
<module name="springmvc-01-523" />
|
||||
<module name="demo516" />
|
||||
<module name="demo515" />
|
||||
<module name="spring-mybatis01-522-523" />
|
||||
<module name="springboot-524" />
|
||||
<module name="mybatis519" />
|
||||
<module name="springmvc-02-524" />
|
||||
<module name="spring522-annotation" />
|
||||
<module name="spring522" />
|
||||
<module name="mybatis516" />
|
||||
<module name="demo516" />
|
||||
<module name="demo515" />
|
||||
<module name="mybatis517-518" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="springboot-524" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
4
.idea/encodings.xml
generated
4
.idea/encodings.xml
generated
@ -21,7 +21,11 @@
|
||||
<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/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/springboot-524/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/springboot-524/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" />
|
||||
<file url="file://$PROJECT_DIR$/springmvc-02-524/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/springmvc-02-524/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@ -4,6 +4,7 @@
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$/demo515" />
|
||||
<file type="web" url="file://$PROJECT_DIR$/springmvc-01-523" />
|
||||
<file type="web" url="file://$PROJECT_DIR$/springmvc-02-524" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
@ -21,6 +22,8 @@
|
||||
<option value="$PROJECT_DIR$/printer-522work/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/spring-mybatis01-522-523/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/springmvc-01-523/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/springmvc-02-524/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/springboot-524/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
43
springboot-524/pom.xml
Normal file
43
springboot-524/pom.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.8</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>springboot-524</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>springboot-524</name>
|
||||
<description>springboot-524</description>
|
||||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
13
springboot-524/src/main/java/cn/czyx007/Application.java
Normal file
13
springboot-524/src/main/java/cn/czyx007/Application.java
Normal file
@ -0,0 +1,13 @@
|
||||
package cn.czyx007;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.czyx007.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author : 张宇轩
|
||||
* @createTime : 2023/5/24 - 15:47
|
||||
*/
|
||||
@RestController
|
||||
public class HelloController {
|
||||
@GetMapping("/hello")
|
||||
public String hello(){
|
||||
return "hello,springboot!!!";
|
||||
}
|
||||
|
||||
@GetMapping("/good")
|
||||
public String good(){
|
||||
return "good,springboot!";
|
||||
}
|
||||
}
|
2
springboot-524/src/main/resources/application.yml
Normal file
2
springboot-524/src/main/resources/application.yml
Normal file
@ -0,0 +1,2 @@
|
||||
#server:
|
||||
# port: 8088
|
@ -0,0 +1,13 @@
|
||||
package cn.czyx007;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
73
springmvc-02-524/pom.xml
Normal file
73
springmvc-02-524/pom.xml
Normal file
@ -0,0 +1,73 @@
|
||||
<?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-02-524</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>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
</dependency>
|
||||
<!--引入json的依赖-->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
@ -0,0 +1,14 @@
|
||||
package cn.czyx007.mvc.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author : 张宇轩
|
||||
* @createTime : 2023/5/24 - 9:09
|
||||
*/
|
||||
@Data
|
||||
public class Condition {
|
||||
private String userName;
|
||||
private Integer age;
|
||||
private String address;
|
||||
}
|
18
springmvc-02-524/src/main/java/cn/czyx007/mvc/bean/User.java
Normal file
18
springmvc-02-524/src/main/java/cn/czyx007/mvc/bean/User.java
Normal file
@ -0,0 +1,18 @@
|
||||
package cn.czyx007.mvc.bean;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author : 张宇轩
|
||||
* @createTime : 2023/5/24 - 9:54
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class User {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String email;
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package cn.czyx007.mvc.controller;
|
||||
|
||||
import cn.czyx007.mvc.bean.User;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author : 张宇轩
|
||||
* @createTime : 2023/5/24 - 10:52
|
||||
*/
|
||||
//@Controller
|
||||
@RestController
|
||||
public class JSONController {
|
||||
|
||||
// @ResponseBody
|
||||
@GetMapping("/json")
|
||||
public String showJson(){
|
||||
return "hello,json!!!";
|
||||
}
|
||||
|
||||
@GetMapping("/json2")
|
||||
// @ResponseBody
|
||||
public Boolean showJson2(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@GetMapping("/getUser")
|
||||
// @ResponseBody
|
||||
public User getUSer(){
|
||||
return new User(1006, "迪丽热巴", "rb@163.com");
|
||||
}
|
||||
|
||||
@GetMapping("/getUserList")
|
||||
// @ResponseBody
|
||||
public List<User> getUserList(){
|
||||
List<User> users = Arrays.asList(
|
||||
new User(1003, "柳岩", "ly@163.com"),
|
||||
new User(1004, "柳岩2", "ly2@163.com"),
|
||||
new User(1005, "柳岩3", "ly3@163.com")
|
||||
);
|
||||
return users;
|
||||
}
|
||||
|
||||
/**
|
||||
* data:封装数据 List<User>
|
||||
* msg:数据返回成功/失败
|
||||
* code:200/500
|
||||
* Map自动转换为JSON格式
|
||||
*/
|
||||
@GetMapping("/getUserMap")
|
||||
// @ResponseBody
|
||||
public Map<String,Object> getUserMap(){
|
||||
Map<String,Object> map = null;
|
||||
try {
|
||||
map = new HashMap<>();
|
||||
List<User> users = Arrays.asList(
|
||||
new User(1003, "柳岩", "ly@163.com"),
|
||||
new User(1004, "柳岩2", "ly2@163.com"),
|
||||
new User(1005, "柳岩3", "ly3@163.com")
|
||||
);
|
||||
map.put("data", users);
|
||||
map.put("msg", "数据返回成功");
|
||||
map.put("code", 200);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
map.put("data", null);
|
||||
map.put("msg", "数据返回失败");
|
||||
map.put("code", 500);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@PostMapping("/getUserJson")
|
||||
public String getUserJson(@RequestBody User user){
|
||||
System.out.println("user = " + user);
|
||||
return "ok";
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package cn.czyx007.mvc.controller;
|
||||
|
||||
import cn.czyx007.mvc.bean.Condition;
|
||||
import cn.czyx007.mvc.bean.User;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author : 张宇轩
|
||||
* @createTime : 2023/5/23 - 11:40
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
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("index");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
// @RequestMapping("/getUser")
|
||||
@GetMapping({"/getUser", "/findUser", "/user01"})
|
||||
public String getUser(Model model){
|
||||
model.addAttribute("address", "北京");
|
||||
return "show";
|
||||
}
|
||||
|
||||
@GetMapping("/show")
|
||||
public String show(
|
||||
@RequestParam(value = "user", required = false, defaultValue = "liuyan") String userName,
|
||||
@RequestParam(value = "age", required = false, defaultValue = "20") Integer age,
|
||||
@RequestParam(value = "address", required = true) String address
|
||||
){
|
||||
System.out.println("userName = " + userName);
|
||||
System.out.println("age = " + age);
|
||||
System.out.println("address = " + address);
|
||||
return "index";
|
||||
}
|
||||
|
||||
@PostMapping ("/showPost")
|
||||
public String showPost(
|
||||
@RequestParam(value = "user", required = false, defaultValue = "liuyan") String userName,
|
||||
@RequestParam(value = "age", required = false, defaultValue = "20") Integer age,
|
||||
@RequestParam(value = "address", required = true) String address
|
||||
){
|
||||
System.out.println("userName = " + userName);
|
||||
System.out.println("age = " + age);
|
||||
System.out.println("address = " + address);
|
||||
return "index";
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/showCondition")
|
||||
public String showCondition(Condition condition){
|
||||
System.out.println("codnition = " + condition);
|
||||
return "index";
|
||||
}
|
||||
|
||||
@PostMapping("/showMap")
|
||||
public String showMap(@RequestParam Map<String,Object> map){
|
||||
Set<Map.Entry<String,Object>> entries = map.entrySet();
|
||||
for (Map.Entry<String, Object> entry : entries) {
|
||||
System.out.println(entry.getKey() + "," + entry.getValue());
|
||||
}
|
||||
return "index";
|
||||
}
|
||||
|
||||
//Restful风格传递数据
|
||||
@GetMapping("/showRestful/{id}/{userName}")
|
||||
public String showRestful(@PathVariable("id") Integer id,
|
||||
@PathVariable("userName") String name){
|
||||
System.out.println("id = " + id);
|
||||
System.out.println("name = " + name);
|
||||
return "index";
|
||||
}
|
||||
|
||||
@GetMapping("/showView")
|
||||
public String showView(Model model){
|
||||
User user = new User(1003, "柳岩", "ly@163.com");
|
||||
model.addAttribute("user", user);
|
||||
return "showUser";
|
||||
}
|
||||
|
||||
@GetMapping("/showViewList")
|
||||
public String showViewList(Model model){
|
||||
List<User> users = Arrays.asList(
|
||||
new User(1003, "柳岩", "ly@163.com"),
|
||||
new User(1004, "柳岩2", "ly2@163.com"),
|
||||
new User(1005, "柳岩3", "ly3@163.com")
|
||||
);
|
||||
model.addAttribute("userList", users);
|
||||
return "showUserList";
|
||||
}
|
||||
|
||||
@GetMapping("/showServlet")
|
||||
public String showServlet(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
HttpSession session,
|
||||
ServletContext context,
|
||||
PageContext pageContext){
|
||||
return "show";
|
||||
}
|
||||
|
||||
@GetMapping("/showViewMap")
|
||||
public String showViewMap(Map<String,Object> map){
|
||||
User user = new User(1003, "柳岩-map", "ly@163.com");
|
||||
map.put("user", user);
|
||||
return "showUser";
|
||||
}
|
||||
}
|
23
springmvc-02-524/src/main/resources/springmvc.xml
Normal file
23
springmvc-02-524/src/main/resources/springmvc.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?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 ">
|
||||
|
||||
<context:component-scan base-package="cn.czyx007.mvc.*"/>
|
||||
<mvc:annotation-driven/>
|
||||
|
||||
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||
<property name="prefix" value="/WEB-INF/jsp/"/>
|
||||
<property name="suffix" value=".jsp"/>
|
||||
</bean>
|
||||
|
||||
<mvc:resources mapping="/statics/**" location="/statics/"/>
|
||||
|
||||
</beans>
|
18
springmvc-02-524/src/main/webapp/WEB-INF/jsp/index.jsp
Normal file
18
springmvc-02-524/src/main/webapp/WEB-INF/jsp/index.jsp
Normal file
@ -0,0 +1,18 @@
|
||||
<%--
|
||||
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}
|
||||
<h1> >>>>这里是index.jsp<<<< </h1>
|
||||
</body>
|
||||
</html>
|
16
springmvc-02-524/src/main/webapp/WEB-INF/jsp/show.jsp
Normal file
16
springmvc-02-524/src/main/webapp/WEB-INF/jsp/show.jsp
Normal file
@ -0,0 +1,16 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: zyx
|
||||
Date: 2023/5/23
|
||||
Time: 14:25
|
||||
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>
|
||||
${address}
|
||||
</body>
|
||||
</html>
|
17
springmvc-02-524/src/main/webapp/WEB-INF/jsp/showUser.jsp
Normal file
17
springmvc-02-524/src/main/webapp/WEB-INF/jsp/showUser.jsp
Normal file
@ -0,0 +1,17 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: zyx
|
||||
Date: 2023/5/24
|
||||
Time: 9:55
|
||||
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>
|
||||
用户数据:
|
||||
${user.id} -- ${user.name} --- ${user.email}
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,20 @@
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: zyx
|
||||
Date: 2023/5/24
|
||||
Time: 9:59
|
||||
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>
|
||||
用户数据:
|
||||
<c:forEach items="${userList}" var="user">
|
||||
${user.id} -- ${user.name} --- ${user.email} <br>
|
||||
</c:forEach>
|
||||
</body>
|
||||
</html>
|
39
springmvc-02-524/src/main/webapp/WEB-INF/web.xml
Normal file
39
springmvc-02-524/src/main/webapp/WEB-INF/web.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?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>
|
||||
|
||||
<filter>
|
||||
<filter-name>encodingFilter</filter-name>
|
||||
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>encoding</param-name>
|
||||
<param-value>utf-8</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>encodingFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
</web-app>
|
10
springmvc-02-524/src/main/webapp/index.html
Normal file
10
springmvc-02-524/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>
|
BIN
springmvc-02-524/src/main/webapp/statics/img.png
Normal file
BIN
springmvc-02-524/src/main/webapp/statics/img.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 773 KiB |
Loading…
x
Reference in New Issue
Block a user