4. SpringBoot中集成jsp展示
时间:2020-10-23 20:45:40
收藏:0
阅读:30
-
SpringBoot框架默认推荐的模板为: Thymeleaf 类似于Freemarker .html 模板
-
Thymeleaf freemarker 模板语法 index.html ===> 欢迎: ${name} ===> 缓存 页面静态化
-
SpringBoot 与 jsp 集成
-
引入依赖 jsp、jstl
<!-- 引入jstl标签,配套jsp使用,可以不导入 -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- 配置内嵌的tomcat解析jsp -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
-
- 在application.yml文件中配置试图解析前缀和后缀,spring.mvc.view.prefix, spring.mvc.view.suffix
spring:
profiles:
# Activate test configuration
active: dev
mvc:
view:
# Configure prefix
prefix: /
# Configure suffix
suffix: .jsp
-
测试通过跳转,新建UserController文件
@Controller
@RequestMapping("user")
public class UserController {
@RequestMapping("findAll")
public String findAll() {
System.out.println("findAll");
return "index";
}
}
-
-
比如这里,可以通过 http://localhost:8989/zq/user/findAll 访问可以打印出findAll,然后跳转index.jsp
- 如果处理完上述操作,仍不支持jsp运行 (新版本似乎不用配置这个)Edit Configuration --> Working directory --> $MODULE_DIR$
-
原文:https://www.cnblogs.com/Lunix-touch/p/13865898.html
评论(0)