亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

spring mvc - HTML表單傳遞請求參數

spring mvc - HTML表單傳遞請求參數

一只名叫tom的貓 2023-10-16 10:58:18
我開始學習Spring MVC和Web開發。我的控制器中有這個方法@GetMapping("/deleteCar")public String deleteCar(@RequestParam("carId") int carid) {    carService.deleteCar(carid);    return "redirect:/car/cars";}如何通過html表單傳遞請求參數?<section>    <form action="${pageContext.request.contextPath}/car/deleteCar">    <input type="text" id="deleteCarWithID" value="${carId}">    </form></section>我收到這個警告:WARNING: Resolved [org.springframework.web.bind.MissingServletRequestParameterException: Required int parameter 'carId' is not present]謝謝你!
查看完整描述

1 回答

?
慕容森

TA貢獻1853條經驗 獲得超18個贊

您缺少名稱屬性,因此請name在輸入字段中使用參數名稱提及屬性。嘗試下面的代碼相同。還添加一個提交類型按鈕來提交表單。

<input type="text" name="carId" id="deleteCarWithID" value="${carId}">


查看完整回答
反對 回復 2023-10-16
  • 1 回答
  • 0 關注
  • 105 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號