帮忙看看为什么在页面不能显示错误信息loginaction代码段
public class LoginAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
LoginForm loginform=(LoginForm)form;
String username=loginform.getUsername();
String password=loginform.getPassword();
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try {
DataSource ds = getDataSource(request);
conn = ds.getConnection();
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from users where bianhao='"+username+"' and password='"+password+"'";
rs=stmt.executeQuery(sql);
if(rs.next()){
return mapping.findForward("Suceess");
}
} catch (SQLException e) { }finally{
try{
rs.close();
stmt.close();
conn.close();
}catch(Exception e){e.printStackTrace();}
}
ActionErrors error=new ActionErrors();
if(!error.isEmpty()){
error.add("loginwrong",new ActionError("jsp.login.wrong"));
saveErrors(request,error);
}
return mapping.findForward("Fail");
}
jsp页面用<html:errors property="loginwrong" />显示页面错误资源文件中 jsp.login.wrong=用户名密码错误
public class LoginAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
LoginForm loginform=(LoginForm)form;
String username=loginform.getUsername();
String password=loginform.getPassword();
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try {
DataSource ds = getDataSource(request);
conn = ds.getConnection();
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from users where bianhao='"+username+"' and password='"+password+"'";
rs=stmt.executeQuery(sql);
if(rs.next()){
return mapping.findForward("Suceess");
}
} catch (SQLException e) { }finally{
try{
rs.close();
stmt.close();
conn.close();
}catch(Exception e){e.printStackTrace();}
}
ActionErrors error=new ActionErrors();
if(!error.isEmpty()){
error.add("loginwrong",new ActionError("jsp.login.wrong"));
saveErrors(request,error);
}
return mapping.findForward("Fail");
}
jsp页面用<html:errors property="loginwrong" />显示页面错误资源文件中 jsp.login.wrong=用户名密码错误
MSN:[email protected]
E-mail:[email protected]
论坛:http://linlin520.cc.topzj.com
主页:www.linlin520.any2000.com
职业:软件工程师
语言:英语3级,日语入门
开发:JAVA,Hibernate,Spring,Struts,Ajax,JSP
工具:Eclipse,Tomcat,Weblogic
数据库:Oracle,MySql,Sql Server 2000,Access
其他语言:Html,Xml,C#(Winform,Asp.net,VB.net),C,C++,VB,ASP,JavaScript
MSN:[email protected]
E-mail:[email protected]
论坛:http://linlin520.cc.topzj.com
主页:www.linlin520.any2000.com
职业:软件工程师
语言:英语3级,日语入门
开发:JAVA,Hibernate,Spring,Struts,Ajax,JSP
工具:Eclipse,Tomcat,Weblogic
数据库:Oracle,MySql,Sql Server 2000,Access
其他语言:Html,Xml,C#(Winform,Asp.net,VB.net),C,C++,VB,ASP,JavaScript