亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Springboot訪(fǎng)問(wèn)templates html頁(yè)面過(guò)程詳解

 更新時(shí)間:2020年05月26日 08:37:33   作者:幻影黑子  
這篇文章主要介紹了Springboot訪(fǎng)問(wèn)templates html頁(yè)面過(guò)程詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

springboot項(xiàng)目默認(rèn)是不允許直接訪(fǎng)問(wèn)templates下的文件的,是受保護(hù)的。

如果要訪(fǎng)問(wèn)templates下的文件,推薦使用thymeleaf。

注:使用thymeleaf這一點(diǎn)要牢牢記??!

如何使用:

1、pom依賴(lài)

<!--thymeleaf 模板依賴(lài)-->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

2、配置文件

#模板熱部署、禁用 thymeleaf 緩存
spring.thymeleaf.cache=false

3、html文件位于resources的templates/目錄下,例如

注意html文件名,這里使用goodsShow,在不區(qū)分大小寫(xiě)的情況下與后臺(tái)返回字符串匹配

4、后臺(tái)返回字符串形式訪(fǎng)問(wèn)html(也可以使用ModelAndView,這里不做展示)

@Controller
@RequestMapping("/goods")
public class GoodsController {
  private static final Logger log = LoggerFactory.getLogger(GoodsController.class);

  @GetMapping
  public String goodsShow() {
    return "goodsShow";
  }
}

5、瀏覽器訪(fǎng)問(wèn)輸入:ip:端口號(hào)/上下文根/goods

本地訪(fǎng)問(wèn):localhost:端口號(hào)/上下文根/goods

例如:localhost:8080/goods

6、具體項(xiàng)目可以參考:https://github.com/guocanzhen/jQueryAjaxJavaWeb

里面還附有jQuery AJAX在springboot中的應(yīng)用。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論