添加新用户时的SQL:insert into userinfo(username,password,userdes) values ('大师','123','操作员')添加新用户时的SQL:insert into userinfo(username,password,userdes) values ('肉味儿','123','null')
同样是添加操作,但是第三个字段userdes在表单里获取值的时候,如果取得是别名就能能正常显示,如果取得名字和数据库字段名一样就显示null,这是怎么回事,高手指点一下

解决方案 »

  1.   

    这要看你表单的name是什么 不是看数据库
      

  2.   

    <%@ page contentType="text/html; charset=gb2312" language="java"%><html>
    <head>
        <title>无标题页</title>
        <link href="style.css" rel="stylesheet" type="text/css" />
        <script>   
      function checkForm(form){
    if(form.username.value==""){
    alert("请输入新用户姓名!");form.username.focus();return false;
    }
    if(form.password.value==""){
    alert("请输入新用户密码!");form.userword.focus();return false;
    }
    if(form.userDes.value==""){
    alert("请输入新用户权限!");form.userDes.focus();return false;
    }
      }
    </script> 
    </head>
    <body>
    <%
    String result = request.getParameter("result");
    if(null != result) {
    out.println("<script>alert('新用户添加成功!');</script>");
    }
    %>
         <form name="Form1" method="post" action="UserAction.do?action=add">
    <table width="600" border="0" cellpadding="0" cellspacing="0"
    align="center">
    <tr style="color: blue; font-size: 14px;">
    <td style="height: 14px; width: 502px;">
    <img src="images/ADD.gif" width="14px" height="14px">
    系统管理--&gt;添加新用户
    </td>
    </tr>
    <tr>
    <td style="height: 42px">
    <br />
    用户姓名:
    <input name="username" type="text" id="username" size="20">
    <br />
    <br />
    用户密码:
    <input name="password" type="text" id="password" size="12">
    <br />
    <br />
    用户权限:
    <input name="userDes" type="text" id="userDes" size="12">
    <br />
    <br />
    &nbsp;
    <input type="submit" value="添加" onclick="return checkForm(Form1);">
    </td>
    </tr>
    </table>
    &nbsp;&nbsp;
             
        </form>
    </body>
    </html>
    就是这一行得到的值是null
      

  3.   

    <input name="userDes" type="text" id="userDes" size="12"> 
    这行的name="userDes"是跟程序里面的userdes一样?
    还是页面是userDes中的D是大写,程序是小写,这样肯定获取不到值肯定是null