1. 服務端頁面跳轉
@RequestMapping("/addWebsite")
public ModelAndView addWebsite()
{
return new ModelAndView("websiteConf/addWebsite");
}
//不加路徑代表默認進入的函數(shù)
@RequestMapping
public String getPage() {
return "/framework/webmanage/adminFields";
}
2. 服務器端接受參數(shù)
/*POST請求時
@RequestBody --> JSON字符串部分 (@RequestBody Map map)
@RequestParam --> 請求參數(shù)部分 (@RequestParam Map map)
GET請求中
不可以使用@RequestBody
使用@RequestParam在url中的?后面添加參數(shù)即可使用
*/
@RequestMapping("/edit")
public ModelAndView editPage(@RequestParam(value = "id", required = false) String id) {
return new ModelAndView("/framework/webmanage/editField", model);
}
//取得路徑中的變量
@RequestMapping("/delete/{ids}")
public String deleteUser(@PathVariable String ids) {
}
3. 服務端接受form表單
參數(shù)注入到實體類中,并實現(xiàn)客戶端頁面跳轉
//表單中標簽元素name屬性與實體類中屬性名對應即可自動注入
@RequestMapping(value="/addWebsiteToDatabase",method = RequestMethod.POST)
public String addWebsiteToDatabase(CrawlerWebsite crawlerWebsite)
{
this.crawlerWebsiteService.insert(crawlerWebsite);
return "redirect:/adminWebsite";
}
4. 服務端接收請求并返回數(shù)據(jù)娃殖,
@RequestMapping("/getConstraintListData")
@ResponseBody
public Map<String, List<CrawlerItemConstraint>> getConstraintListData(Model model) {
List<CrawlerItemConstraint> demos = service....獲得數(shù)據(jù)
Map<String, List<CrawlerItemConstraint>> resultMap = new HashMap<>();
resultMap.put("datas", demos);
return resultMap;
}