mvc html页面传值,spring mvc传值 html取值 ╰+攻爆jí腚メ 2022-10-06 04:48 128阅读 0赞 Controller中: @Controller @RequestMapping(value="") public class IndexController \{ @RequestMapping(value = "/trackStationInfo/\{trackId\}") public String getTrackStation(Model model, @PathVariable String trackId)\{ model.addAttribute("trackId",trackId); return "trackStationInfo"; \} \} 或者 @RequestMapping(value = "/trackStationInfo") public String getTrackStation(Model model, String trackId)\{ model.addAttribute("trackId",trackId); return "trackStationInfo"; \} 页面中 Insert title here 如果是第一种controller写法: ajax中: url:"/api/station/getStationByStationName/"+stationName, 网页中打开:localhost:6999/trackStationInfo/\{26\} 其中26为trackId 如果是第二种controller写法: ajax中: url: "/api/equipment/getEquipment/?trackId="+trackId, 网页中打开:localhost:6999/trackStationInfo?trackId=26 其中26为trackId
还没有评论,来说两句吧...