首页 新闻 会员 周边 捐助

jsp添加数据报错?请大神帮忙看一下。

0
[已解决问题] 解决于 2015-05-07 14:59

这是源码。

</body>

 1 <%@page contentType="text/html" pageEncoding="UTF-8"%>
 2 <%@page import="java.sql.*" %>
 3 <!DOCTYPE html>
 4 <html>
 5     <head>
 6         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 7         <title>处理客户添加数据</title>
 8     </head>
 9     <body>
10         <%
11             //String clientName = new String(request.getParameter("clientName").getBytes("ISO-8859-1"),"UTF-8");
12             String clientName = new String(request.getParameter("clientName").getBytes("ISO-8859-1"),"UTF-8");
13             String clientTelephone = new String(request.getParameter("clientTelephone").getBytes("ISO-8859-1"),"UTF-8");
14             String clientAddress = new String(request.getParameter("clientAddress").getBytes("ISO-8859-1"),"UTF-8");
15             String clientEmail = new String(request.getParameter("clientEmain").getBytes("ISO-8859-1"),"UTF-8"); 
16             Connection con = null;
17             Statement st = null;
18             try{
19                 Class.forName("com.mysql.jdbc.Driver");
20                 //String url = "jdbc:mysql://localhost:3306/eims?useUnicode=true&characterEcoding=gbk";
21                 String url = "jdbc:mysql://localhost:3306/eims?useUnicode=true&characterEcoding=gbk";
22                 con = DriverManager.getConnection(url,"root","123");
23                 st = con.createStatement();
24                 String sql = "insert into client(clientName,clientTelephone,clientAddress,clientEmail) values('"+clientName+"','"+clientTelephone+"','"+clientAddress+"','"+clientEmail+"')";
25                 //st.executeQuery(sql);
26                 st.executeQuery(sql);
27                 response.sendRedirect("http;//localhost:8084/EIMS/clientManage/lookClient.jsp");
28             }catch(Exception e){
29                 e.printStackTrace();
30             }finally{
31                 st.close();
32                 con.close();
33             }
34         %>
35         
36     </body>

报错截图:

西皮眼光的主页 西皮眼光 | 初学一级 | 园豆:194
提问于:2015-04-24 16:09
< >
分享
最佳答案
0

404那个是添加时候的路径问题,你用相对路径吧,在地址前面加上<%pageContext.request.contextPath%>/clientManage/lookClientCheck.jsp

奖励园豆:5
丢了幸福的猪227 | 菜鸟二级 |园豆:261 | 2015-04-24 16:45

谢谢,我已找到错误。不过你的建议很不错。

西皮眼光 | 园豆:194 (初学一级) | 2015-04-27 15:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册