SpringBoot系列三之MVC模版引擎Spring Boot spring mvc
更多⼲货
Spring boot 在spring默认基础上,⾃动配置添加了以下特性金色的鱼钩课文
模板引擎的选择
注:jsp应该尽量避免使⽤,原因如下:
FreeMarker 例⼦
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId> </dependency>
<dependency>
<groupId>org.webjars</groupId>
炉具清洁剂
西洋参片的作用与功效<artifactId>jquery</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
天上人间电视剧<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
爵士舞教学<scope>test</scope>
</dependency>
开在心中的花</dependencies>
WebController.java
@Controller
@RequestMapping(value = "/web")
public class WebController {
@RequestMapping(value = "index")
public String index(ModelMap map) {
map.put("title", "freemarker hello word");
return "index"; // 开头不要加上/,linux下⾯会出错 }
一叶扁舟
}
SpringBootDemo61Application
@ServletComponentScan
@SpringBootApplication
家访手记public class SpringBootDemo61Application {
public static void main(String[] args) {
SpringApplication.run(SpringBootDemo61Application.class, args); }
}
⽬录结构
├── java
│├── com.eva.learn
│││
││└── controller controller
││
│
├── resources
││
│├── static 静态⽂件
││
│├── templates 页⾯模版