提交用例
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
package com.heibaiying.springboot;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringBootJspApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringBootJspApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.heibaiying.springboot.bean;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author : heibaiying
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Programmer {
|
||||
|
||||
private String name;
|
||||
|
||||
private int age;
|
||||
|
||||
private float salary;
|
||||
|
||||
private LocalDate birthday;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.heibaiying.springboot.controller;
|
||||
|
||||
import com.heibaiying.springboot.bean.Programmer;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author : heibaiying
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping("index")
|
||||
public class JspController {
|
||||
|
||||
@RequestMapping
|
||||
public String jsp(Model model){
|
||||
Programmer programmer = new Programmer("heibai", 21, 1298.31f, LocalDate.now());
|
||||
model.addAttribute("programmer",programmer);
|
||||
return "show";
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
spring:
|
||||
mvc:
|
||||
view:
|
||||
prefix: /WEB-INF/jsp/
|
||||
suffix: .jsp
|
@ -0,0 +1,13 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>programmer</title>
|
||||
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/show.css">
|
||||
</head>
|
||||
<body>
|
||||
<ul>
|
||||
<li>姓名: ${programmer.name}</li>
|
||||
<li>年龄: ${programmer.age}</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
4
spring-boot/spring-boot-jsp/src/main/webapp/css/show.css
Normal file
4
spring-boot/spring-boot-jsp/src/main/webapp/css/show.css
Normal file
@ -0,0 +1,4 @@
|
||||
li{
|
||||
font-size: 30px;
|
||||
color: blueviolet;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.heibaiying.springboot;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SpringBootJspApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user