springMVC do web projects turn into topics for springboot web project

Background article:

An old web project is springMVC do need to modify some recent function, and then start Tomcat using locally deployed during startup various error in the online version of the Baidu for a long time is spring issue, entangled for some time, finally the turn springboot idea, no longer control the various versions of compatibility issues.

Project conversion steps are as follows:

1) Create a new empty project springboot

2) add a web related dependencies in pom.xml

<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--配置servlet--> 
<dependency> 
<groupId>javax.servlet</groupId> 
<artifactId>javax.servlet-api</artifactId> 
</dependency> 
<!--配置jsp jstl的支持--> 
<dependency> 
<groupId>javax.servlet</groupId> 
<artifactId>jstl</artifactId> 
</dependency> 
<!--对jsp的支持--> 
<dependency> 
<groupId>org.apache.tomcat.embed</groupId> 
<artifactId>tomcat-embed-jasper</artifactId> 
</dependency>

 

3) According to the original directory directly copy the original project in Java code such as HTML pages into a new project, in addition to static resources

    src / main / java and src / main direct copy of the webapp directory under / over

4) In addition to static HTML pages and other resources outside, you need to place the file in the resource directory folder under static

  In the src / main / resource directory New Folder static, then a direct copy of the original project to the next static static resource files

 

5) to modify the original HTML pages, etc., reference path static resources (if the original project is an absolute path, removed off the original absolute path into a relative path)
  time because of problems SpringBoot mechanism, reference css or js files, you must first place the file in static folder, and then when the static reference not written on the path, as shown below

 

 

Modified:

 

6) other configurations, such as a data connection, the configuration logs

  If it is a simple configuration, the configuration file does not exist, add the configuration file can be directly application.properties,

  If the configuration file, in application.properties, configure load configuration file

As the following configuration template path and the path of jsp page freeMarker

 

Guess you like

Origin www.cnblogs.com/sunshine2017/p/11458086.html