java jsp 表单提交到数据库

wenwen1 发布于 2012/08/21 13:25
阅读 4K+
收藏 0

我的newCustomer.jsp如下:

<%@ page language="java" import="java.util.*" import="java.sql.*" contentType="text/html;charset=UTF-8" pageEncoding="utf-8"%>
<%@ page session="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增客户信息</title>
    <style type="text/css">
        label{
            width:100px;
            display:block;
        }   
    </style>
    <link rel="stylesheet" type="text/css" href="../../jquery/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../jquery/themes/icon.css">
    <script type="text/javascript" src="../../jquery/js/Calendar.js"></script>
    <script type="text/javascript" src="../../jquery/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="../../jquery/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../js/getNewProject.js">
   
    </script>
</head>
<body>
    <div style="background:#fafafa;padding:10px;">
        <form id="ff" action="newCustomInfoSub.jsp" method="post">
            <fieldset>
           <legend>客户信息(带*号为必填项)</legend>
            <table>
            <tr><td align="right"><label for="khbh">客户编号*:</label></td>
           <td><input class="easyui-validatebox" type="text" name="name" required="true"></input></td>
             <td align="right"><label for="khmc">客户名称*:</label></td>
             <td> <input input class="easyui-validatebox" type="text" name="name" required="true"></input></td></tr>
            <tr><td align="right"><label for="bmmc">部门名称:</label></td>
           <td><input class="easyui-validatebox" type="text" name="name" required="true"></input></td>
             <td align="right"><label for="bmfzr">部门负责人:</label></td>
             <td> <input class="easyui-validatebox" type="text" name="name" required="true"></input></td></tr>
                     </table>
            <table>
               <tr><td> <label for="bmzn">部门职能:</label></td>
              <td> <textarea name="bmzn" style="height:60px; width:450px;"></textarea></td></tr>
                  <tr><td> <label for="khjbxx">客户基本信息:</label></td>
              <td> <textarea name="khjbxx" style="height:60px; width:450px;"></textarea></td></tr>
                  <tr><td> <label for="bz">备注:</label></td>
              <td> <textarea name="bz" style="height:60px; width:450px;"></textarea></td></tr>
            </table>
   </fieldset>
           <span style="display:block; width:500px; text-align:right">
         <input type="submit" name="button" value="提交"/>
         <input type="button" name="button" value="重置" onclick="this.form.reset()"/>    
          </span>           
        </form>
    </div>
   
</body>
</html>
 newCustomInfoSub.jsp的代码如下:

<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="utf-8"%>
<jsp:useBean id="dbConn" class="pack_convert.DBConnXmgl"/>
<%@ page session="true" %>

  <%
 
  request.setCharacterEncoding("utf-8");//处理乱码
  String khbh = request.getParameter("khbh");
  String khmc = request.getParameter("khmc");
  String bmmc = request.getParameter("bmmc");
  String bmzn = request.getParameter("bmzn");
  String bmfzr = request.getParameter("bmfzr");
  String khjbxx = request.getParameter("khjbxx");
  String bz = request.getParameter("bz");
 
  String sql1 = "select * from customer where khbh='"+khbh+"'";
  ResultSet rs = dbConn.doQuery(sql1);
  if(rs.next()){
    out.println("{\"该客户编号已存在,请检查后重新输入。\"}");
  }else{
   
  String sql = "insert into customer(khbh,khmc,bmmc,bmzn,bmfzr,khjbxx,bz) values ('"+khbh+"','"+khmc+"','"+bmmc+"','"+bmzn+"','"+bmfzr+"','"+khjbxx+"','"+bz+"')";
  boolean bol = dbConn.Sql(sql);
  if(bol){
        out.println("{\"success\":\"true\",\"msg\":\"添加成功!\"}");
   }else{
        out.println("{\"failure\":\"failure\",\"msg\":\"出错了,请重新操作!\"}");
   }
  //out.println("<a href=../../vender/jsp/newVender.jsp>1秒后自动跳转...</a>");
  }
        dbConn.releaseConn();//释放链接

  %>

为什么我在页面输入数据后点击提交按钮就报如下错:

HTTP Status 404 - /xmgl_jquery/customer/jsp/newCustomInfoSub.jsp

type Status report

message /xmgl_jquery/customer/jsp/newCustomInfoSub.jsp

description The requested resource (/xmgl_jquery/customer/jsp/newCustomInfoSub.jsp) is not available.

Apache Tomcat/6.0.32

这是为什么呢?怎么解决啊?我的newCustomInfoSub.jsp和newCustomer.jsp是放在同一文件中的。

加载中
0
一号男嘉宾
一号男嘉宾

HTTP Status 404

表示没有找到这个页面,你看看路径是不是写错了。
wenwen1
wenwen1
我另一页面也是这么写的,却可以提交。
返回顶部
顶部