Springboot Jump JSP page

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.