日期:2014-05-18  浏览次数:20587 次

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)actionF