首页 > 编程语言 > 详细

springboot中访问html页面

时间:2019-08-27 20:05:57      阅读:178      评论:0      收藏:0      [点我收藏+]

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页面

原文:https://www.cnblogs.com/shuaifing/p/11420094.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!