码迷,mamicode.com
首页 > 编程语言 > 详细

springboot中访问html页面

时间:2020-06-13 17:19:04      阅读:64      评论:0      收藏:0      [点我收藏+]

标签:spring   ping   depend   pre   pid   app   bsp   一个   方法   

springboot中如果想访问html页面,不每访问一个页面就写一个Controller,可以统一写一个公共的controller方法

代码:

(1)引入hutool工具依赖

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

 

(2)公共Controller

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

 (3)访问页面路径

如页面路径在demo下,配置文件中servlet.context-path: /test

技术图片

 

 

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

springboot中访问html页面

标签:spring   ping   depend   pre   pid   app   bsp   一个   方法   

原文地址:https://www.cnblogs.com/telwanggs/p/13117788.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!