0
我有這樣一段代碼:Spring MVC映射 - 爲什麼路徑正在改變?
@RequestMapping(value="login/authUser", method=RequestMethod.POST)
public String authUser(@RequestParam("login") String login,
@RequestParam("password") String password, ModelMap model)
(...)
哪些應該抓住用戶的身份驗證:
<div id ="loginBar">
<form id="loginForm" action="login/authUser" method="post">
<label>Login:</label>
<input id="login" type="text" title="podaj login" name="login"/><br><br>
<label>Hasło:</label>
<input id ="password" type="password" title="podaj haslo, minimum 8 znaków" name="password"><br>
<input id ="loginAuthorisationFailed" type="text"/><br>
<input id="loginButton" type="submit" value="Zaloguj"><br>
</form>
</div>
如果這是不好的,它應該返回index.jsp和有關壞數據
(...)
else{
model.put("info", "Bad data!");
return "index";
信息轉至h1 HTML標籤:
<h1>${info}</h1>
這是路徑,然後我看到瀏覽器:
http://localhost:8084/pracainz/login/authUser
但後來我嘗試再次登錄,在瀏覽器的路徑是不同的:
http://localhost:8084/pracainz/login/login/authUser
和Tomcat顯示我的錯誤:
The requested resource() is not available.
它增加了額外的「/登錄」,我不知道爲什麼。我能做些什麼來阻止以這種方式形成行爲,我能做些什麼,每次強制路徑,,復位」當我嘗試發送形式春天
不幸的是,這是行不通的:?
action="${pageContext.servletContext.contextPath}/login/authUser"
我將非常高興,如果有人想幫我
預先感謝您
解決:! 解決方案:
我應該使用:
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
(...)
<form:form id="loginForm" action="${pageContext.servletContext.contextPath}/login/authUser" method="post">
(...)
</form:form>
而是簡單的HTML標籤
謝謝,我也發現不同的解決方案;我應該用春天標籤代替簡單HMTL