Springboot訪問(wèn)html頁(yè)面步驟解析
springboot中如果想訪問(wèn)html頁(yè)面,不每訪問(wèn)一個(gè)頁(yè)面就寫(xiě)一個(gè)Controller,可以統(tǒng)一寫(xiě)一個(gè)公共的controller方法
代碼:
(1)引入hutool工具依賴(lài)
<!-- 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訪問(wèn)控制器/** * @return */@RequestMapping(value = '/view/**', method = RequestMethod.GET)public String html(HttpServletRequest request) { return StrUtil.removePrefix(request.getRequestURI(), request.getContextPath() + '/view');}
(3)訪問(wèn)頁(yè)面路徑
如頁(yè)面路徑在demo下,配置文件中servlet.context-path: /test

則lhttp://localhost:8081/test/view/demo/...../XXX.html
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 詳解Android studio 動(dòng)態(tài)fragment的用法2. 編程語(yǔ)言PHP在Web開(kāi)發(fā)領(lǐng)域的優(yōu)勢(shì)在哪?3. Android如何加載Base64編碼格式圖片4. 基于android studio的layout的xml文件的創(chuàng)建方式5. Spring Boot和Thymeleaf整合結(jié)合JPA實(shí)現(xiàn)分頁(yè)效果(實(shí)例代碼)6. 解決Android studio xml界面無(wú)法預(yù)覽問(wèn)題7. 什么是python的自省8. 圖文詳解vue中proto文件的函數(shù)調(diào)用9. Springboot Druid 自定義加密數(shù)據(jù)庫(kù)密碼的幾種方案10. Vuex localStorage的具體使用

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