In springboot integration method thymeleaf jump page template engine @Controller and different annotations @RestController

Note: This article is purely learning record, for subsequent review!

1. Implement the page jump through @RestController notes:

H5 corresponding to static pages

2. Use the page jump achieve @Controller comment

H5 corresponding to static pages:

The main reason why there will be two kinds of annotations @RestController @Controller and implement different ways jump page is:

By @RestController source @Controller know @RestController is a combination of notes and @ResponseBody

 

If you need to jump to a specific page, use @Controller annotations and view resolvers InternalResourceViewResolver used in conjunction.

To return JSON, or XML content from mediaType defined, on the need to add annotations @ReponseBody corresponding method.

But if you use @RestController annotations, view resolver InternalResourceViewResolver fail, can not be resolved html, jsp page and then jump to a specific page, but returns the contents of return, and this time if you need to return to a specific page,

You need the following:

 Sample Code: https: //gitee.com/JamieLove7/SpringAllTest/tree/master/spring-boot-thymeleaf

 

Guess you like

Origin www.cnblogs.com/JamieLove/p/11204509.html