Spring Boot integrated JSP

Source: Internet
Author: User
Tags spring boot tutorial

Use idea to write a small program based on the spring boot framework to implement decryption functionality. Front-end pages are basically not required, can be as simple as how simple, so directly in the spring boot project to integrate a JSP page.

New spring Boot project, online a lot of new spring boot tutorial, casual Baidu.

Create a good project, write a hellocontroller run it, and if it works, start integrating the JSP:

The first step: Add two dependent packages to Pom.xml as follows:

<dependency>    <groupId>javax.servlet</groupId>    <artifactid>jstl</artifactid >    <version>1.2</version></dependency><dependency>    <groupId> org.apache.tomcat.embed</groupid>    <artifactId>tomcat-embed-jasper</artifactId>    <! --<scope>provided</scope>--></dependency>
With the piece, look good:

Step Two: Src/main/resources the following application.properties files are set as follows:

spring.mvc.view.suffix=. Jspspring.mvc.view.prefix=/web-inf/jsp/

Most of the online tutorials have this, but commenting out seems to work, but with more insurance.

Step three: Under the main directory, create the WEBAPP directory structure: Webapp/web-inf,

Fourth step: Set up in project structure:

After entering, click Modules, the following page appears:

If the following web is not present in the project demo, click on the plus sign above the demo project to create it:

Select the Web, the following page appears, 1, you need to add the Web directory path you just created under Web Resource directories. 2, need to add a Web. XML in Deployment descriptors:

On the Web Resource directories click the plus sign on the right, add the third step to create the web directory structure:

Click the directory selector on the right, select WebApp, and click OK:

Add a Web. xml to Deployment descriptors:

Click the plus sign on the right side of deployment descriptors, select 1 web. xml

Modify the directory structure in which Web. XML is located to Src/main/webapp/web-inf:

Click OK to enter the following page:

Note: There is no web. xml file in this directory structure, remember to add it after Web-inf: \web.xml

This will create the Web. xml file under the Webapp/web-inf directory. (hang in here for a long time)

Click Ok,ok to return to the project interface:

Spring Boot integrated JSP is configured, then you can create a index.jsp under the WebApp directory, run the program, to see if it can run properly:

Warm tip: Remember to configure your JSP page in Web. Xml. The results of the operation are as follows:

Fear bird eggs: The above summary may have errors and omissions of the place, hoping to get feedback from readers! We exchange and learn from each other!



Spring Boot integrated JSP

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.