I have this piece of code:
@RequestMapping(value="login/authUser", method=RequestMethod.POST)
public String authUser(@RequestParam("login") String login,
@RequestParam("password") String password, ModelMap model)
(...)
Which should catch user's authentication:
<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>
And if it's bad, it should return index.jsp and information about bad data
(...)
else{
model.put("info", "Bad data!");
return "index";
Info goes to the h1 HTML tag:
<h1>${info}</h1>
And this is path then I see in browser:
http://localhost:8084/pracainz/login/authUser
But then I try to log again, path in browser is different:
http://localhost:8084/pracainz/login/login/authUser
and Tomcat shows me error:
The requested resource () is not available.
It adds extra "/login" and I don't know why. What can I do to stop form behaving in this way, what can I do to force ,,reset" of path every time when I try to send form to Spring?
Unfortunately, this is not working:
action="${pageContext.servletContext.contextPath}/login/authUser"
I would be very happy if anybody want to help me.
Thank you in advance!
SOLVED: Solution:
I should use:
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
(...)
<form:form id="loginForm" action="${pageContext.servletContext.contextPath}/login/authUser" method="post">
(...)
</form:form>
Instead simple HTML tag