1.springboot Why is it not recommended to use JSP?
Reference Address: Https://spring.io/blog/2012/10/30/spring-mvc-from-jsp-and-tiles-to-thymeleaf
2. What are the advantages of using the Freemark template engine?
Reference Address: http://blog.csdn.net/qq897958555/article/details/53560655
3. Code implementation
1). pom.xml
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <groupId>com.lf</groupId> <artifactId> Springbootinjsp</artifactid> <version>0.0.1-SNAPSHOT</version> <packaging>war</ Packaging> <!--inherit Spring-boot-starter-paren-<parent> <groupid>org.springframework.b Oot</groupid> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.3.rel Ease</version> </parent> <dependencies> <!--springboot Core components--<dependenc Y> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter- Web</artifactid> </dependency> <!--add JSP support--<dependency> <groupId>org.apache.tomcat.embed</groupId> <ARTIFACTID>TOMCAT-E Mbed-jasper</artifactid> </dependency> </dependencies></project>
2). Indexcontroller.java
PackageCom.lf.controller;Importorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.EnableAutoConfiguration;ImportOrg.springframework.stereotype.Controller;Importorg.springframework.web.bind.annotation.RequestMapping, @Controller @enableautoconfiguration Public classIndexcontroller {@RequestMapping ("Index") PublicString Index () {return"Index"; } Public Static voidMain (string[] args) {Springapplication.run (indexcontroller.class, args); }}
3). index.jsp
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 " pageencoding=" UTF-8 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
4). Test
Springboot: Make Web project support JSP