springboot access html page

If you want to visit springboot in html page, not every visit a page to write a Controller, you can write a common unified method of controller

Code:

(1) introducing tools rely hutool

  <!-- hutool工具包-->
<dependency>
<groupId>com.xiaoleilu</groupId>
<artifactId>hutool-all</artifactId>
<version>3.3.0</version>
</dependency>

 

(2) Public Controller

com.xiaoleilu.hutool.util.StrUtil import ;
//html访问控制器
/**
* @return
*/
@RequestMapping(value = "/view/**", method = RequestMethod.GET)
public String html(HttpServletRequest request) {
return StrUtil.removePrefix(request.getRequestURI(), request.getContextPath() + "/view");
}

 (3) access Page path

The path at page demo, profile the servlet. Context-path: / Test

则lhttp://localhost:8081/test/view/demo/...../XXX.html



Guess you like

Origin www.cnblogs.com/shuaifing/p/11420094.html