What should be mentioned in the action property of a form tag in jsp?
What should @RequestMapping corresponds to?
This is the example i am trying -
Home.jsp
<form:form method="get" action = "login">
<table>
<tr><td></td><td><input type = "submit" value = "Login"/></td></tr>
</table>
</form:form>
LoginController.java
@Controller
public class LoginController {
@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView validateLogin()
{
String lsQuery = "select count(*) from UserAuth where userid = 'anirba' and password = 'Lahiri0ni'";
Connection con1; PreparedStatement ps;ResultSet rs;
Map<string,string> model = new HashMap<string,string>();
ModelAndView lObjMV = new ModelAndView();
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con1 = DriverManager.getConnection("Jdbc:mysql://localhost/SpringApp", "root", "lahiri");
ps = con1.prepareStatement(lsQuery); rs = ps.executeQuery();
if(rs.next())
{
if(rs.getInt(0) > 0)
{
lObjMV.setViewName("successLog");
//lsViewName = "successLog";
}
else
{
lObjMV.setViewName("failureLog");
//lsViewName = "failureLog";
}
}
lObjMV.addObject(model);
}
catch(Exception lObjS) {}
return lObjMV;
//return lsViewName;
}
}
and two simple jsp pages Namely successLog.jsp and failureLog.jsp for success and failure.
There is no Login.jsp.
When executed its asking for one.
As i know, one gives the request relative url to @RequestMapping of a Controller function. Controller then forwards it to the required view.
Please correct me where am i going wrong.
Thanks in advance.