资源简介
适用初学者 大二jsp期末项目
1、建立正确的javabean类
2、编写javabean属性和方法
3、用到jdbc驱动程序连接数据
4、对数据库增删改查
5、使用PreparedStetement接口
代码片段和文件信息
package fjzzy.org;
import java.io.IOException;
import java.io.PrintWriter;
import fjzzy.org.*;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class AddServlet
*/
@WebServlet(“/AddServlet“)
public class AddServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public AddServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
// TODO Auto-generated method stub
//response.getWriter().append(“Served at: “).append(request.getContextPath());
request.setCharacterEncoding(“gbk“);
response.setContentType(“text/html“);
response.setCharacterEncoding(“gbk“);
HttpSession session=request.getSession(true);//定义session
PrintWriter out=response.getWriter();//定义out
String bookid= request.getParameter(“bookid“);
String bookname= request.getParameter(“bookname“);
String booktype= request.getParameter(“booktype“);
String bookwriter= request.getParameter(“bookwriter“);
String bookdetail= request.getParameter(“bookdetail“);
String bookprice= request.getParameter(“bookprice“);
String bookstock= request.getParameter(“bookstock“);
String bookimgsrc= request.getParameter(“bookimgsrc“);
boolean w=false;
ConnDB c=new ConnDB();
String sql=“insert into book values(????????)“;
int i=c.insert(sql bookid bookname booktype bookwriter bookdetail bookprice bookstock bookimgsrc);
if(i!=0){
out.println(““);
out.println(“tle>1 tle>ript> alert(‘录入成功!‘); ript>“);
out.println(““);
out.println(““);
out.println(““);
response.setHeader(“Refresh““0.01;URL=Admin1.jsp“);
}else{
out.println(““);
out.println(“tle>1 tle>ript> alert(‘录入失败!‘); ript>“);
out.println(““);
out.println(““);
out.println(““);
response.setHeader(“Refresh“ “0.01;URL=Admin1.jsp“);
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {
// TODO Auto-generated method stub
doGet(request response);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-10 13:39 Work\
文件 944 2018-01-20 01:16 Work\.classpath
文件 904 2018-01-05 23:05 Work\.project
目录 0 2018-01-10 13:39 Work\.settings\
文件 567 2018-01-05 23:05 Work\.settings\.jsdtscope
文件 364 2018-01-05 23:05 Work\.settings\org.eclipse.jdt.core.prefs
文件 464 2018-01-05 23:05 Work\.settings\org.eclipse.wst.common.component
文件 305 2018-01-20 01:16 Work\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2018-01-05 23:05 Work\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2018-01-05 23:05 Work\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2018-01-20 13:28 Work\WebContent\
文件 2614 2018-01-19 20:54 Work\WebContent\Admin.jsp
文件 4828 2018-01-22 11:34 Work\WebContent\Admin1.jsp
文件 5200 2018-01-19 20:55 Work\WebContent\Admin2.jsp
文件 3818 2018-01-19 20:55 Work\WebContent\Admin3.jsp
文件 5736 2018-01-22 16:35 Work\WebContent\Admin4.jsp
文件 4863 2018-01-22 11:29 Work\WebContent\Admin5.jsp
文件 2812 2018-01-22 17:39 Work\WebContent\JieYueChe.jsp
文件 2905 2018-01-21 16:09 Work\WebContent\Login.html
文件 2156 2018-01-22 15:40 Work\WebContent\Login_ok.jsp
目录 0 2018-01-10 13:39 Work\WebContent\me
文件 39 2018-01-05 23:05 Work\WebContent\me
文件 6513 2018-01-22 16:16 Work\WebContent\ShiShi.jsp
文件 3470 2018-01-22 16:16 Work\WebContent\SouSuo.jsp
文件 6315 2018-01-20 14:04 Work\WebContent\SouSuo_ok.jsp
文件 486 2018-01-19 21:29 Work\WebContent\Tuichu.jsp
目录 0 2018-01-10 13:39 Work\WebContent\WEB-INF\
目录 0 2018-02-08 20:26 Work\WebContent\WEB-INF\lib\
文件 6464 2018-01-22 21:08 Work\WebContent\WenXue.jsp
文件 4883 2018-01-19 20:53 Work\WebContent\XiuGai.jsp
文件 6481 2018-01-22 16:17 Work\WebContent\YouSheng.jsp
............此处省略159个文件信息
- 上一篇:SSM集成socket 实时
- 下一篇:Java图形界面-MySQL-增删改查
评论
共有 条评论