servlet + jsp project into springboot + jsp + maven

1. First set up an empty springboot project.

2. Add the integration servlet with jsp files need to rely on prom.xml springboot project:

3. application.properties configuration file:

## JSP configuration (when the page jump directly write / WEB-INF / jsp / rear portion to .jsp)
# page default prefix
spring.mvc.view.prefix = / WEB-INF / jsp /
# default page response suffix
spring.mvc.view.suffix = .jsp such as:

# Use ServletFileUpload upload files (the old project file upload servlet is ServletFileUpload, so the spring is turned off)
spring.http.multipart.enabled = false

4. web.xml arranged in the servlet transformed into SPRINGMVC (in AdminServlet example)

Such a change service layer with the same layer dao

Because dao layer to interact with the database using a QueryRunner, if the persistent manner springboot provided to change the feeling of the code will increase a lot, but with QueryRunner, it must provide c3p0-config.xml configuration file, so here's resource package there c3p0-config.xml file under:

5. The next step is static style, js, image storage location (this is key, it is best to configure according to the original jsp page references a directory, or to change things on more), such as:

This style reference main.css I like this, I need to set up springboot engineering static resource storage location:

Engage in a class, the location pointed to static storage resource today the following:

So when this reference style, or the original: /jsps/css/main.css. What other pictures also built according to the original directory in a static directory, and then put the resources into them, such page references resources almost do not change.

6. Then the original jsp page calls need to change it:

7. Finally engage in a filter, the need to intercept the request set about:

In this class there MyFilter write their own processing logic.

8. Summary:

Such a change need to change something fairly small, because, after all, is an old project to switch to a different frame, I think the code aspects, especially in terms of SQL, if raw mybatis change or hibernate, it also increased a lot SQL configuration file, code changes also It will be much larger, so the changes as small as possible.

Released five original articles · won praise 1 · views 10000 +

Guess you like

Origin blog.csdn.net/star_zone/article/details/84346973