首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求教!JSP+MYSQL注册页面传递的数据,处理页面无法获取,该怎么处理

2012-03-14 
求教!JSP+MYSQL注册页面传递的数据,处理页面无法获取本来是通过jsp+mysql实现一个注册功能的,可是老是连接

求教!JSP+MYSQL注册页面传递的数据,处理页面无法获取
本来是通过jsp+mysql实现一个注册功能的,可是老是连接报错,我就想看一下数据输出是否正常,于是去掉SQL插入语句,改成输出语句,结果注册填什么东西,点解注册按钮之后,输出全都是null
这是我的源代码(非常不规范,见笑了!):
register.jsp:

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>supplierManagement</title>
</head>

<body>
<form action="register_deal.jsp" method="post" enctype="multipart/form-data" name="form13" id="form13">
  <table width="409">
  <tr>
  <th width="108" scope="col">ICP备案号</th>
  <th width="289" scope="col"><div align="left">
  <input type="text" name="ICP" />
  </div></th>
  </tr>
  <tr>
  <th scope="row">名称</th>
  <td><input type="text" name="name" /></td>
  </tr>
  <tr>
  <th scope="row">公司简介</th>
  <td><textarea name="brief"></textarea></td>
  </tr>
  <tr>
  <th scope="row">供应品</th>
  <td><select name="material">
  <option>蔬菜</option>
  <option>肉类</option>
  </select>
  </td>
  </tr>
  <tr>
  <th scope="row">报价</th>
  <td><input type="text" name="price" /></td>
  </tr>
  <tr>
  <th scope="row">地址</th>
  <td><input type="text" name="address" /></td>
  </tr>
  <tr>
  <th scope="row">电话</th>
  <td><input type="text" name="telephone" /></td>
  </tr>
  <tr>
  <th scope="row">邮箱</th>
  <td><input type="text" name="email" /></td>
  </tr>
  <tr>
  <th scope="row">合格证</th>
  <td><input type="file" name="certification" /></td>
  </tr>
  <tr>
  <th scope="row">检疫合格证</th>
  <td><input type="file" name="certification2" /></td>
  </tr>
  <tr>
  <th scope="row"><input type="submit" name="Submit3" value="提交" /></th>
  <td><div align="center">
  <input type="reset" name="Submit4" value="重置" />
  </div></td>
  </tr>
  </table>
</form>
</body>
</html>

register_deal.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" errorPage="" %>



<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>My JSP 'register_deal.jsp' starting page</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>
  
  <body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url= "jdbc:mysql://localhost:3306/graduationproject?user=root&password=123&useUnicode=true&characterEncoding=GB2312";
Connection connection=DriverManager.getConnection(url); 
Statement statement = connection.createStatement();
request.setCharacterEncoding("gb2312");
String ICP=request.getParameter("ICP");
String name=request.getParameter("name");
String brief=request.getParameter("brief");
String material=request.getParameter("material");
String price2=request.getParameter("price");
String address=request.getParameter("address");
String telephone2=request.getParameter("telephone");
String email=request.getParameter("email");
String certification=request.getParameter("certification");
String certification2=request.getParameter("certification2");

%>
<% 
out.print(ICP);
out.print(name);
out.print(brief);
out.print(material);
out.print(price2);
out.print(address);
out.print(telephone2);
out.print(email);
out.print(certification);
out.print(certification2);
 %>
  </body>
</html>

请问是什么问题?要如何修改啊?

[解决办法]
可是老是连接报错。

查看下你驱动放在lib下了没有

我就想看一下数据输出是否正常,输出全都是null。

<form action="register_deal.jsp" method="post" enctype="multipart/form-data" name="form13" id="form13">

把 enctype="multipart/form-data" 去掉

热点排行