Jaa*_*nus 0 java spring jsp spring-mvc request
当前控制器代码:
@RequestMapping(value = "/city", method = RequestMethod.POST)
public String getWeather(@RequestParam("city") int city_id,
@RequestParam("text") String days, //this gives errrors, when i remove this line, then it is okay
Model model) {
logger.debug("Received request to show cities page");
//int city =
// Attach list of subscriptions to the Model
model.addAttribute("city", service.getCity(city_id));
// This will resolve to /WEB-INF/jsp/subscribers.jsp
return "city";
}
Run Code Online (Sandbox Code Playgroud)
这是我的JSP文件(视图):
<form method="post" action="/spring/krams/show/city">
Vali linn
<select name="city">
<c:forEach items="${cities}" var="city">
<option value="<c:out value="${city.id}" />"><c:out value="${city.city}" /></option>
</c:forEach>
</select><br>
Vali prognoos N päeva kohta(kirjuta 1 hetkese ilma jaoks)
<input type="text name="text">
<input type="submit" value="Test" name="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)
我想从名为TEXT的文本框中获取一个值,但是当我按下提交按钮然后我得到
HTTP Status 400 - The request sent by the client was syntactically incorrect ().
Run Code Online (Sandbox Code Playgroud)
我正在添加这个答案,以便您可以接受它,因为Bozho建议:)
HTML中似乎存在问题:
<input type="text name="text">
将其更改为
<input type="text" name="text">并尝试.
我认为语法错误意味着@RequestParam注释中指定的名称与请求参数名称不匹配...可能是因为HTML中的上述错误.
| 归档时间: |
|
| 查看次数: |
16204 次 |
| 最近记录: |