最近做了一個springboot項目,前後端不分離。前端使用的是springboot官方推薦的Themleaf引擎模板。因爲筆者是做java的,並不是前端高手。所以正如標題所說,淺談… 也是希望寫了這篇博客能夠從本質上幫助到大家
首先說下
$(document).ready(function(){
}
注意看我的textTree.html頁面這裏的代碼,標註黃色的部分,請求的就是我的後臺接口路徑。
@RequestMapping("column")
@Controller
@Api(description = "欄目管理",tags = "欄目管理")
public class SysColumnController {
@RequestMapping(value = "/all")
@ResponseBody
@ApiOperation(value = "所有欄目", notes = "下拉框欄目列表", produces = "application/json")
public List<SysColumn> listAll() {
List<SysColumn> list = sysColumnService.listAll();
return list;
}
}
意思是隻要是加載我的textTree.html這個頁面,就會自動向後臺發送請求,並且接口路徑爲column/all。
下面再說iframe標籤
注意看我截圖標註黃色部分的並且使用紅線標註的部分
src="/text/textList"
表示src請求的接口路徑是/text/textList
@RequestMapping("text")
@Controller
@Api(description = "文章API",tags = "文章API")
public class SysTextController extends UploadController {
@RequestMapping("/textList")
@ApiOperation(value = "去欄目管理頁面", notes = "欄目管理", produces = "application/json")
public String columnTable() {
return "text/textList";
}
}
同樣是只要是加載我的textTree.html這個頁面,就會自動向後臺發送請求,並且接口路徑爲text/textList
最後再跟大家說一下小知識點
JQuery中
$(function(){
})
和
$(document).ready(function(){
})
語法是一致的,只不過$(function(){})是縮寫版
這輩子堅持與不堅持都不可怕,怕的是對子走在堅持的道路上!
歡迎加入技術羣聊!