Spring Boot web开发
Spring Boot web开发一、在Spirng Boot中使用JSP1.需要引入tomcat-embed-jasper依赖<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-s
·
Spring Boot web开发
常用注解
@Controller
@RestController
@RequestMapping
@ResponseBody
@GetMapping
@PathVariable
@PostMapping
@RequestParam
@PutMapping
@DeleteMapping
三、更换Web容器
Spring boot web默认使用tomcat容器,可以更换为jetty
- 排除spring-boot-starter-tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
-
加入spring-boot-starter-jetty
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency>
四、Spring Boot 访问静态资源
src/main/webapp
目录下,可以直接访问(org.springframework.boot.autoconfigure.web.ResourceProperties
)- 默认静态资源路径是:
classpath:[/META-INF/resources/,/resources/,/static/,/public/]
- 可以通过
spring.resources.staticLocations
进行配置
更多推荐
已为社区贡献2条内容
所有评论(0)