idea springboot+springsecurity项目html界面跳转
2018-03-16 20:04
483 查看
1.不用thymeleaft 模板,直接controller层跳转
controller层跳转
@RequestMapping("/")
public String index1()
{
return "index1.html";
}
----------------------------------------------------------------------------------------------------------------
index1.html文件放在main->webapp下
如果项目路径不是默认webaap 文件。可以通过project struction ->modules->添加web ,设置路径为"/";
2.用thymeleaft 模板,直接controller层跳转
controller层跳转
@RequestMapping("/")
public String index1()
{
return "index1";
}
(1).在写controller层之前,需要先引入maven 依赖
具体在pom.xml文件中添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>(2).在application.properties/application.yml 中加入
spring.thymeleaf.view.prefix=/WEB-INF/templates/
spring.thymeleaf.view.suffix=.jsp
-----------------------------------------------------------------------------------
index1.html 需要放在WEB-INF->templates文件夹中
3.用thymeleaf 模板,继承WebMvcConfigureAdapter重写addViewControllers 方法
在方法里添加controller
@Override extends
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index1");
}
springboot版本记得降级,
由于目前在idea中直接创建springboot项目,springboot 的父依赖版本一般为2.0.0.release,记得改为1.4.3.release版本
否则无法继承WebMvcConfigureAdapter
(1).在写controller层之前,需要先引入maven 依赖
具体在pom.xml文件中添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>(2).在application.properties/application.yml 中加入
spring.thymeleaf.view.prefix=/WEB-INF/templates/
spring.thymeleaf.view.suffix=.jsp
controller层跳转
@RequestMapping("/")
public String index1()
{
return "index1.html";
}
----------------------------------------------------------------------------------------------------------------
index1.html文件放在main->webapp下
如果项目路径不是默认webaap 文件。可以通过project struction ->modules->添加web ,设置路径为"/";
2.用thymeleaft 模板,直接controller层跳转
controller层跳转
@RequestMapping("/")
public String index1()
{
return "index1";
}
(1).在写controller层之前,需要先引入maven 依赖
具体在pom.xml文件中添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>(2).在application.properties/application.yml 中加入
spring.thymeleaf.view.prefix=/WEB-INF/templates/
spring.thymeleaf.view.suffix=.jsp
-----------------------------------------------------------------------------------
index1.html 需要放在WEB-INF->templates文件夹中
3.用thymeleaf 模板,继承WebMvcConfigureAdapter重写addViewControllers 方法
在方法里添加controller
@Override extends
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index1");
}
springboot版本记得降级,
由于目前在idea中直接创建springboot项目,springboot 的父依赖版本一般为2.0.0.release,记得改为1.4.3.release版本
否则无法继承WebMvcConfigureAdapter
(1).在写controller层之前,需要先引入maven 依赖
具体在pom.xml文件中添加
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>(2).在application.properties/application.yml 中加入
spring.thymeleaf.view.prefix=/WEB-INF/templates/
spring.thymeleaf.view.suffix=.jsp
相关文章推荐
- IDEA 快速搭建springboot项目,返回HTML首页
- 解决:sprng boot 项目在IDEA中spring-boot run正常运行,但是打成JAR包之后访问界面返回404
- idea快速搭建springboot项目的操作方法
- springboot 在idea多模块下 子模块的web项目用内置tomcat启动访问jsp报404
- idea spring boot项目导入提示找不到主类
- 使用idea+springboot+Mybatis搭建web项目
- 使用IDEA搭建SpringBoot项目且整合mongoDB和mysql
- 快速创建springboot项目:使用http://start.spring.io/网页创建,使用IDEA的Spring Initializr创建,使用SpringBoot CLI创建
- 使用idea+springboot+Mybatis搭建web项目
- IDEA中SpringBoot项目启动遇到端口被占用(Address already in use: bind)
- springBoot系列-IDEA 创建springBoot项目
- 关于springBoot项目在IDEA中热部署问题
- Spring Boot实战【用IDEA新建springBoot 项目】
- 使用Idea新建Spring Boot项目
- idea创建springboot项目图文教程(四)
- IntelliJ IDEA工具创建入门的springBoot项目
- 从零开始通过idea插件将一个spring boot项目部署到docker容器里运行
- Idea使用Maven创建多模块SpringBoot项目问题记录
- 在IDEA中将SpringBoot项目打包成jar包的方法
- SpringBoot基础教程及框架整合(一)----IDEA创建SpringBoot项目