java jsp中form表单提交到数据

wenwen1 发布于 2012/08/22 10:25
阅读 16K+
收藏 0

我的ptProject.jsp如下:

<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title>项目明细计划填报</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
        label{
            width:120px;
            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">
    <link rel="stylesheet" type="text/css" href="../../jquery/css/demo.css">
    <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>
  </head>
 
  <body>
  <form id="vender" action="ptProjectSub.jsp" method="post">
 <fieldset>
           <legend>项目基本信息(带*号为必填项)</legend>
            <table>
           <tr><td align="right"><label for="xmmc">项目名称*:</label></td>
           <td><input class="easyui-validatebox" type="text" name="name" required="true"></input></td>
           <td align="right"><label for="ywmc">英文名称*:</label></td>
             <td> <input class="easyui-validatebox" type="text" name="name" required="true"></input></td></tr>
          <tr><td align="right"><label for="xmbh">项目编号*:</label></td>
           <td><input class="easyui-validatebox" type="text" name="name" required="true"></input></td>
             <td align="right"><label for="yjjf">研究经费*:</label></td>
             <td><input class="easyui-validatebox" type="text" name="name" required="true"></input></td></tr>
            <tr><td align="right"><label for="yjkssj">研究期限*:</label></td>
           <td><input class="easyui-datebox" required="true" type="text" name="name" ></input></td>
             <td align="right"><label for="yjjssj">至:</label></td>
             <td><input class="easyui-datebox" required="true" type="text" name="name" ></input></td></tr>
            <tr><td><label for="zwkeyword">中文关键词*:</label></td>
           <td><input class="easyui-validatebox" type="text" name="name" required="true" ></input></td>
            <td align="right"><label for="ywkeyword">英文关键词*:</label></td>
           <td><input class="easyui-validatebox" type="text" name="name" required="true"></input></td></tr>
                     </table>
            <table>
               <tr><td> <label for="xmnr">项目内容*:</label></td>
              <td> <textarea name="xmnr" style="height:60px; width:450px;" required="true"></textarea></td></tr>
                  <tr><td> <label for="gnwqs">国内外趋势*:</label></td>
              <td> <textarea name="gnwqs" style="height:60px; width:450px;" required="true"></textarea></td></tr>
              <tr><td> <label for="lxyy">立项意义*:</label></td>
              <td> <textarea name="lxyy" style="height:60px; width:450px;" required="true"></textarea></td></tr>
              <tr><td> <label for="yjjz">研究价值*:</label></td>
              <td> <textarea name="yjjz" style="height:60px; width:450px;" required="true"></textarea></td></tr>
             </table>
          </fieldset>
         <span style="display:block; width:500px; text-align:right">
         <input type="submit" name="submit" value="保存" />
         <input type="reset" name="button" value="修改" />
         <input type="button" name="button" value="下一步"/>
        </span>
</form>   
  </body>
</html>

我的ptProjectSub.jsp如下:

<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="utf-8"%>
<jsp:useBean id="dbConn" class="pack_convert.DBConnXmgl"/>
  <%
 
  request.setCharacterEncoding("utf-8");//处理乱码
  String xmmc = request.getParameter("xmmc");
  String xmbh = request.getParameter("xmbh");
  String ywmc = request.getParameter("ywmc");
  String yjjf = request.getParameter("yjjf");
  String yjkssj = request.getParameter("yjkssj");
  String yjjssj = request.getParameter("yjjssj");
  String xmnr= request.getParameter("xmnr");
 // String fax = request.getParameter("fax");
  String gnwqs= request.getParameter("gnwqs");
  String yjyy= request.getParameter("yjyy");
  String lxyy= request.getParameter("lxyy");
  String zwkeyword= request.getParameter("zwkeyword");
  String ywkeyword= request.getParameter("ywkeyword");
 
  String sql1 = "select * from project_plan where xmbh='"+xmbh+"'";
  ResultSet rs = dbConn.doQuery(sql1);
  if(rs.next()){
    out.println("{\"该项目已存在,请检查后重新输入。\"}");
  }else{
   
  String sql = "insert into project_plan(xmmc,xmbh,ywmc,yjjf,yjkssj,yjjssj,xmnr,gnwqs,yjyy,lxyy,zwkeyword,ywkeyword) values ('"+xmmc+"','"+xmbh+"','"+ywmc+"','"+yjjf+"','"+yjkssj+"','"+yjjssj+"','"+xmnr+"','"+gnwqs+"','"+yjyy+"','"+lxyy+"','"+zwkeyword+"','"+ywkeyword+"')";
  boolean bol = dbConn.Sql(sql);
  if(bol){
       out.println("{\"success\":\"true\",\"msg\":\"添加成功!\"}");
  }else{
       out.println("{\"failure\":\"failure\",\"msg\":\"出错了,请重新操作!\"}");
  }
  }
        dbConn.releaseConn();//释放链接
  response.setHeader("Refresh","1; URL=ptProject.jsp");//12秒后自动跳转页面

  %> 

但是我按保存按钮时一点反应都没有呢?

加载中
0
鉴客
鉴客

但是我按保存按钮时一点反应都没有呢?

这是一个用户应该提的问题,而不是一个程序员应该提的问题

 

0
wenwen1
wenwen1
我是新手,刚刚学习,这个到底哪里有错啊?怎么保存不了呢?
0
Gillian_Male
Gillian_Male
你在 ptProjectSub.jsp页面可以得到你的所有的参数值吗?
wenwen1
wenwen1
可以的,这个问题我已经解决了,现在是在做jquery的修改和删除操作,这个该怎么做啊?
返回顶部
顶部