Springboot訪問html頁面步驟解析
springboot中如果想訪問html頁面,不每訪問一個(gè)頁面就寫一個(gè)Controller,可以統(tǒng)一寫一個(gè)公共的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
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. PHP輸入流php://input的使用分析2. CentOS郵箱服務(wù)器搭建系列——SMTP服務(wù)器的構(gòu)建( Postfix )3. ASP新手必備的基礎(chǔ)知識4. asp文件用什么軟件編輯5. 利用Java對PDF文件進(jìn)行電子簽章的實(shí)戰(zhàn)過程6. Docker 啟動(dòng)Redis 并設(shè)置密碼的操作7. PHP與MYSQL數(shù)據(jù)庫連接8. 詳解PHP laravel中的加密與解密函數(shù)9. IntelliJ IDEA恢復(fù)刪除文件的方法10. PHP基礎(chǔ)之生成器4——比較生成器和迭代器對象

網(wǎng)公網(wǎng)安備