<div id="loginCtrl" style="display: true">
<TABLE height=75 cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
  <TR>
    <TD align=right width="95%" height=28>
    <P align=left><FONT color=#5e5e5e>&nbsp;登陆帐号:</FONT>
    <html:text name="indexForm" property="userName" />
    </P></TD>
  <TR>
    <TD align=right height=28>
    <P align=left><FONT color=#5e5e5e>&nbsp;登陆密码:</FONT>
    <html:text name="indexForm" property="passWord" /></P></TD>
</TBODY>
</TABLE>
</div>
<div id="loginCtrl2" style="display:none">
<TABLE height=75 cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
  <TR>
    <TD align=right width="95%" height=28>
    <P align=left><FONT color=#5e5e5e>&nbsp;登陆帐号:</FONT>
    <bean:write name="indexForm" property="userName" />
    </P></TD>
  <TR>
    <TD align=right height=28>
    <P align=left><FONT color=#5e5e5e>&nbsp;登陆密码:</FONT>
    <bean:write name="indexForm" property="passWord" /></P></TD>
</TBODY>
</TABLE>
</div>
这是我的提交页面,我用隐藏form提交的,然后让第一个div隐藏,第二个div显示,主要是为了局部刷新。让页面显示那个登陆的人的名字。
但是怎么也不显示。form中有值得,我用alert显示了,但是不知道为什么这个<bean:write>没有值。
说明:本页面的form没有提交,只是隐藏的form提交了,并作了相应的操作。谢谢大家帮助,我是第一次来这里问问题。还请帮助。

解决方案 »

  1.   

    找了半天没找到<form>标签
      

  2.   

    出发这个jsp后包括页面难道没有任何的异常吗?
      

  3.   

    我写form了。<html:form method="post" action="/indexAction.do" style="indexForm">
    就是这样写的,在div之前。
    没有任何异常,我的jsp也后台出现异常,前台也不报错,就白板什么也不现实。
    大哥们,帮帮忙吧
      

  4.   

    你在indexAction中能不能out出你要在页面上的值,如果有,那么就是你页面的问题了
      

  5.   

    后台什么错?
    会不会是没的提交或找不到action?
      

  6.   

    indexForm 没有存到容器里
    当你用 <bean:write name="indexForm" property="userName" />无法将userName输出
    你仔细看看<bean:write 的试用说明
      

  7.   

    function setLoginDiv(){
             document.getElementById("loginCtrl").style.display="none";//隐藏
    document.getElementById("loginCtrl2").style.display="";//显示
    alert(indexForm.userName.value);
    alert(indexForm.passWord.value);
    }
    我用隐藏form调用了这个父界面的函数,就是这个有要显示的有div的页面,alert都能打出值来,就是<bean:write>里没有值
      

  8.   

    <%@ page contentType="text/html; charset=UTF-8"%>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%><html:html>
    <HEAD>
    <TITLE>天津高校自由二手交易</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=UTF-8">
    <LINK href="css/inc_style.css" type=text/css rel=stylesheet>
    <script language=javaScript src="/js/ajax.js"></script>
    <STYLE type=text/css>
    BODY {
    BACKGROUND-COLOR: #cccccc
    }
    </STYLE>
    <script type="text/javascript">function login(){
    if(checkForm()){
    checkform.target="checkiframe";
    checkform.userName.value=indexForm.userName.value;
    checkform.passWord.value=indexForm.passWord.value;

    checkform.action="./loginAction.do";
    checkform.submit();
    }}
    function checkForm(){
    if(document.indexForm.userName.value.length<1){
        alert("用户名不能为空!");
        return false;
    }
    if(document.indexForm.passWord.value.length<1){
        alert("密码不能为空!");
        return false;
    }
    return true;
    }
    function putData(gdName){
    indexForm.gdName.value = gdName;
    indexForm.action = "./contentAction.do";
    indexForm.submit();
    }
    function toRegister(){
    indexForm.action = "./registerAction.do";
    indexForm.submit();
    }
    function setLoginDiv(){ document.getElementById("loginCtrl").style.display="none";//隐藏
    document.getElementById("loginCtrl2").style.display="";//显示
    alert(indexForm.userName.value);
    alert(indexForm.passWord.value);
    }
    </script></HEAD>
    <BODY topMargin=0>
    <%@ include file="header.jsp"%>
    <html:form method="post" action="/indexAction.do" styleId="indexForm">
    <html:hidden property="gdName"/>
    <html:text property="mode"/><div align="center">
    <TABLE height=341 cellSpacing=0 cellPadding=0 width=768 bgColor=#ffffff border=0>
      <TBODY>
      <TR>
        <TD height=262>
          <TABLE height=321 cellSpacing=0 cellPadding=0 width=768 border=0>
            <TBODY>
            <TR>
              <TD vAlign=top width=176 background="" height=321>
                <DIV align=left>
                <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 height=258 cellSpacing=0 cellPadding=0 width="98%" border=0>
                  <TBODY>
                  <TR>
                    <TD height=104>
                      <DIV align=center>
                      <CENTER>
                      <TABLE class=font_10_e_blue style="BORDER-COLLAPSE: collapse" borderColor=#111111 height=107 cellPadding=0 width=171 border=0>
                        <TBODY>
                        <TR>
                          <TD width=244><IMG src="picture/a0.gif" border=0></TD></TR>
                        <TR>
                          <TD width=244 height=80>
                           <div id="loginCtrl" style="display: true">
                          
                           <TABLE height=75 cellSpacing=0 cellPadding=0 width="100%">
    <TBODY>
    <TR>
    <TD align=right width="95%" height=28>
       <P align=left><FONT color=#5e5e5e>&nbsp;登陆帐号:</FONT>
       <html:text name="indexForm" property="userName" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px" maxlength="20" size="13" /></P></TD>
    <TR>
    <TD align=right height=28>
       <P align=left><FONT color=#5e5e5e>&nbsp;登陆密码:</FONT>
       <html:password name="indexForm" property="passWord" maxlength="32" size="13" /></P></TD>
       <TR>
    <TD>
       <P align=center>
       <html:button onclick="javascript:login();"  property="button1" /> [
       <a href="#" onclick="toRegister();"/>注册</A>]</P></TD>
                              </TR>
      </TBODY>
    </TABLE>
                          
                           </div>
                           <div id="loginCtrl2" style="display: true" >
                          
                             <TABLE height=75 cellSpacing=0 cellPadding=0 width="100%">
    <TBODY>
    <TR>
    <TD align=right width="95%" height=28>
       <P align=left><FONT color=#5e5e5e>&nbsp;登陆帐号:</FONT>
       <bean:write name="indexForm" property="userName" />
       </P></TD>
    </TR>
    <TR>
    <TD align=right height=28>
       <P align=left><FONT color=#5e5e5e>&nbsp;登陆密码:</FONT>
       <bean:write name="indexForm" property="passWord" /></P></TD>
    </TR>
       </TBODY>
    </TABLE>
                      
                       </div>
                     </TD>
                   </TR>
                   </TBODY>
               </TABLE>
           </CENTER>
          
    <%@ include file="bottom.jsp"%>
    </html:form>
    </BODY>
    <FORM name="checkform" action="" method="post"> 
    <INPUT type="hidden" name="mode">
    <INPUT type="hidden" name="userName">
    <INPUT type="hidden" name="passWord">
    </FORM>
    <iframe name="checkiframe" marginheight="0" marginwidth="0" frameborder="0" width="0" height="0"></iframe>
    </html:html>