Springboot Support JSP page jump
The official does not recommend JSP support, personally think JSP in the Web layer, with Tomcat support is better
1. Create a MAVEN Project project
<Projectxmlns= "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.woms.www</groupId> <Artifactid>Springboot</Artifactid> <version>0.0.1-snapshot</version> <Packaging>Jar</Packaging> <Parent> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-starter-parent</Artifactid> <version>1.3.5.RELEASE</version> </Parent> <Dependencies> <Dependency> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-starter-web</Artifactid> </Dependency> <!--Tomcat Support - <Dependency> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-starter-tomcat</Artifactid> <Scope>Provided</Scope> </Dependency> <Dependency> <groupId>Org.apache.tomcat.embed</groupId> <Artifactid>Tomcat-embed-jasper</Artifactid> <Scope>Provided</Scope> </Dependency> <!--JSP Tag Library - <Dependency> <groupId>Javax.servlet</groupId> <Artifactid>Jstl</Artifactid> </Dependency> </Dependencies> <Build> <Plugins> <plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-compiler-plugin</Artifactid> <Configuration> <Source>1.8</Source> <Target>1.8</Target> <encoding>Utf-8</encoding> </Configuration> </plugin> <plugin> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-maven-plugin</Artifactid> </plugin> </Plugins> </Build></Project>
The main focus here is to introduce the Tomcat support and JSTL tag Library
2.application.properties configuration file
#springmvcspring. mvc.view.prefix:/web-inf/jsp/spring.mvc.view.suffix:.jsp
3. Create a startup class and controller test
Packagecom.woms;Importorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.SpringBootApplication;//the @springbootapplication annotation is equivalent to using @configuration, @EnableAutoConfiguration, and @componentscan with default properties. @SpringBootApplication Public classstringbootapplication { Public Static voidMain (string[] args) {//TODO auto-generated Method StubSpringapplication.run (stringbootapplication.class, args); }}
PackageCom.woms.controller;ImportOrg.springframework.stereotype.Controller;ImportOrg.springframework.ui.Model;Importorg.springframework.web.bind.annotation.RequestMapping;ImportOrg.springframework.web.bind.annotation.RestController;//@RestController@Controller @requestmapping ("/login") Public classUsercontroller {//@RestController equivalent to @[email protected] (the JSON string is returned by default on each method)@RequestMapping ("/initlogin") PublicString Initlogin (model model) {Model.addattribute ("Model", "Model: Are you supported?"); return"Hello"; } @RequestMapping ("/") PublicString Welcome () {return"Index"; }}
Reference official has a sample, the address is:
Https://github.com/spring-projects/spring-boot/tree/v1.1.5.RELEASE
There's a spring-boot\spring-boot-samples\spring-boot-sample-web-jsp running on his own.
Springboot Jump JSP page