In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about the introduction of static files in Springboot. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Introduction of org.springframework.boot spring-boot-starter-thymeleaf optional configuration in thymeleaf mode dependency
If you have
Some class references to WebMvcConfigurationSupport. You need to let them go.
If you quote springSecurity,
You also need to let them go.
Thymeleaf needs to switch to view layer through controller layer
Import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RestController;import org.springframework.web.servlet.ModelAndView / * @ ClassName: * @ Author: sansy * @ Date: 2019-5-16 10:12 * @ Version: 2.0 * / @ RestControllerpublic class IndexController {@ RequestMapping (value = "/ index", method = RequestMethod.GET) public ModelAndView index () {System.out.println ("/ index enters the controller controller"); ModelAndView mav = new ModelAndView (); mav.setViewName ("index"); return mav } @ RequestMapping (value = "/ home", method = RequestMethod.GET) public ModelAndView home () {System.out.println ("/ home enters the controller controller"); ModelAndView mav = new ModelAndView (); mav.setViewName ("index"); return mav } @ RequestMapping (value = "/ error", method = RequestMethod.GET) public ModelAndView error () {System.out.println ("/ error enters the controller controller"); ModelAndView mav = new ModelAndView (); mav.setViewName ("index"); return mav } @ RequestMapping (value = "/ login", method = RequestMethod.GET) public ModelAndView login () {System.out.println ("/ login enters the controller controller"); ModelAndView mav = new ModelAndView (); mav.setViewName ("index"); return mav } @ RequestMapping (value = "/", method = RequestMethod.GET) public ModelAndView indexs () {System.out.println ("/ enter the controller controller"); ModelAndView mav = new ModelAndView (); mav.setViewName ("index"); return mav } @ RequestMapping (value = "/ 404", method = RequestMethod.GET) public ModelAndView error404 () {System.out.println ("/ 404 enters the controller controller"); ModelAndView mav = new ModelAndView (); mav.setViewName ("index"); return mav;}} yml is configured as follows
To frame like this.
Non-thymeleaf mode first removes dependencies
Delete the view layer that points to controller
You can also bring a controller if you want (point to index if you do. Without it, it points to index by default. Can be understood as an absolute path, a relative path)
This is configured in the yml file
In order to have direct access to the text file in the root directory
The framework is as follows
Done.
Thank you for reading! This is the end of this article on "what are the ways to introduce static files in Springboot?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.