这是源码。
</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>
报错截图:
404那个是添加时候的路径问题,你用相对路径吧,在地址前面加上<%pageContext.request.contextPath%>/clientManage/lookClientCheck.jsp
谢谢,我已找到错误。不过你的建议很不错。