当前位置: 代码迷 >> Java Web开发 >> jsp、struts页面跳转有关问题
  详细解决方案

jsp、struts页面跳转有关问题

热度:33   发布时间:2016-04-17 14:41:00.0
jsp、struts页面跳转问题
登录与注册界面:1.先按下 "登录 ",报 "no   user ",再按下 "注册 ",页面路径错误
                                2.直接按下 "注册 ",没有任何问题
      我写的代码如下:
                      1.jsp
                    <head> <title> <bean:message   key= "title "/> </title> </head>
<script   language= "javascript ">
function   login()
{
document.LoginForm.submit();
}
function   register()
{
window.location= "register.jsp ";
}
</script>
<body   background= "images/bg.gif ">
<html:form   action= "/LoginAction "   focus= "userName ">
<table   bgcolor= "aaff "   width= "100% "   >
<tr>
<td>
<bean:message   key= "userName "/> : <html:text   property= "userName "   name= "userName "   value= " "   size= "10 "/> &nbsp
<bean:message   key= "password "/> : <html:text   property= "password "   name= "password "   value= " "   size= "10 "/>
<logic:messagesPresent   message= "failLogin ">                                                
                        <html:errors   property= "loginFail "/>                                            
                        </logic:messagesPresent>                                        
<input   type= "button "   onclick= "login() "   value= " <bean:message   key= "submit "/> "   /> &nbsp
<input   type= "reset "   value= " <bean:message   key= "reset "/> "/> &nbsp
<input   type= "button "   onclick= "register() "   value= " <bean:message   key= "register "/> "/>
</td>
</tr>
</table>
</html:form>
</body>
 
              2.java--Action
                      public   ActionForward   execute(ActionMapping   mapping,ActionForm   actionForm,
HttpServletRequest   request,HttpServletResponse   response)
{
boolean   bool=false;

ActionErrors   errors=new   ActionErrors();
ActionForward   actionForward=new   ActionForward();

LoginForm   form=(LoginForm)actionForm;
LoginBean   loginBean=new   LoginBean(getDataSource(request,   "sqlServer "));
bool=loginBean.loginCheck(form.getUserName(),form.getPassword());
  相关解决方案