在register.html中写
        <div style="height:50">
        </div>
        <div style="text-align:center;margin:aoto;width:500">
            <script language="JavaScript" src="/day1_2/page/validate">
            </script>
            <form name="form1" method="post" onsubmit="return check()" action="reg.jsp">
                <table align="center">
                    <tr bgcolor="#F8F9BF" align="center">
                        <td colspan="2">
                            <div>
                                注册页面
                                </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    姓名:
                                </td>
                                <td>
                                    <input type="text" name="username" onblur="checkName()";onfocus="dis()"><span id="nameError"></span>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    密码:
                                </td>
                                <td>
                                    <input type="password" name="password1" onblur="checkPwd1()"><span id="pwd1Error"></span>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    确认密码:
                                </td>
                                <td>
                                    <input type="password" name="password2" onblur="checkPwd2()"><span id="pwd2Error"></span>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    性别
                                </td>
                                <td>
                                    男<input type="radio" name="gender" value="male" checked/> 女<input type="radio" name="gender" value="female"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    学历:
                                </td>
                                <td>
                                    <select name="x1">
                                        <option value="cz">初中<option value="gz">高中<option value="zz">中专<option value="dz" selected>大专<option value="db">大本<option value="yjs">研究生
                                                            </select>
                                                        </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                兴趣:
                                                            </td>
                                                            <td>
                                                                旅游<input type="checkbox" name="ah" value="travel"/> 数码产品<input type="checkbox" name="ah" value="digital"/> 服装<input type="checkbox" name="ah" value="cloth"/>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td>
                                                                自我介绍
                                                            </td>
                                                            <td>
                                                                <textarea cols="15" row="3">
                                                                </textarea>
                                                            </td>
                                                        </tr>
                                                        <tr align="center" bgcolor="#F8F9BF">
                                                            <td colspan="2">
                                                                <input type="submit"><input type="reset">
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    </form>
                                                </div>
                                         
在reg.jsp中用<jsp:include>包含register.html中的部分,代码如下
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="java.io.*,com.lijian.jsp.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册</title>
</head>
<body style="text-align: center">
<jsp:include page="/WEB-INF/page/register.html"/>
<%
String username = request.getParameter("username");
String password = request.getParameter("password1");
Properties properties = new Properties();
String resourcePath = "/WEB-INF/classes/resource/jdbcDataResourse.properties";
InputStream is = application.getResourceAsStream(resourcePath);
properties.load(is);
RegBean regBean = new RegBean(properties);
if (regBean.doReg(username, password)) {
request.getRequestDispatcher("login.jsp").forward(request,
response);
}
%>
</body>
</html>问题:每次一访问这个页面http://localhost:9999/day1_2/reg.jsp ,myeclipse控制台就会抛出异常java.sql.SQLException: ORA-01400: 无法将 NULL 插入 ("SCOTT"."T_USR"."USRNAME"),此时我还没有填入相关数据,仅仅是访问这个页面,数据当然是空的,就是不知道异常是由什么引起的,难道在访问reg.jsp页面已经自动提交过一次了?如果这样的话该怎么将自动提交关掉呢,还有每次抛出异常后,我还在reg.jsp填入相关数据后,仍然可以成功更新数据库,就是第一次访问这个也面的时候,会抛出异常,有谁知道该如何解决,原因是什么

解决方案 »

  1.   

    这个问题是oracle的问题,在oracle里随便建一个表,随便插入一条数据,如果数据是字符串类型,你把空字符串插入进去,oracle就会报这个错误,奇怪,不知道怎么解决,我还在找答案。
      

  2.   

    regBean.doReg(username, password)?
      

  3.   

    String username = request.getParameter("username");
                String password = request.getParameter("password1");
    因为你没set,直接get