java - how to get userid and password from database and pass to Method in Spring MVC -
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>user login.</title> </head> <body> <h4>user login.</h4> <form:form method="post" name="loginform" action="login-check"> <table> <tr> <td>user name:</td> <td><form:input path="name" value="${form.name}"/></td> </tr> <tr> <td>password:</td> <td><form:input path="password" value="${form.password}"/></td> </tr> <tr> <td colspan="2" align="right"><input type="submit" value="submit"></td> </tr> </table> <div style="color: red">${error}</div> </form:form> </body> </html>
this controller :
@requestmapping("/login-check") public modelandview logincheck(@modelattribute form person) { // todo auto-generated method stub int value=service.checklogin("name", "password"); if(value>0) { return "loginsucess"; } else { return "failure"; } }
i have form bean class
in have user id
, password
, more field
there getter
, setter
want take input jsp
page , have pass in checklogin method
here define check login
public int checklogin(string username, string userpassword) { // todo auto-generated method stub string sql_query = " form o o.username=? , o.userpassword=?"; int rowcount = jdbctemplate.queryforint(sql_query); return rowcount; }
i trying jsp
input value unable please suggest me how ll sot can apply condition .
you have use count query , set parameter prepared statement:
string sql = "select count(*) form username = ? , o.userpassword=?"; int count = jdbctemplate.queryforint(sql, new object[] { username, userpassword});
Comments
Post a Comment