基于javaweb+mysql的jsp+servlet在线药店管理系统(java+jsp+bootstrap+jquery+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servlet在线药店管理系统(java+jsp+bootstrap+jquery+mysql)
项目介绍
基于jsp+servlet在线药店管理系统。 该项目是一个后管系统,只有一个管理员角色,功能比较简单,适合java初学者或者学生做课程设计等;
主要功能包括:
用户登录、注册;系统管理、药品管理、顾客信息管理、供货商管理、订单管理等;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;
技术栈
- 后端:servlet 2. 前端:JSP+bootstrap+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 3. 将项目中c3p0.properties配置文件中的数据库配置改为自己的配置 4. 运行项目,输入http://localhost:8080/shop 登录 5. 账户admin 密码123456
}
public void showCustomer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showCustomer.....");
List<Customer> customer=customerService.showCustomer();
request.setAttribute("customer", customer);
request.getRequestDispatcher("customer/index.jsp").forward(request, response);
}
public void showCustomerByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showCustomerByPage.....");
String current_page=request.getParameter("current_page");
//先有鸡还是先有蛋。
int count_rows=customerService.counts();
PageTools pt=new PageTools(current_page, count_rows);
List<Customer> customer=customerService.showCustomerByPage(pt);
request.setAttribute("pt", pt);
request.setAttribute("customer",customer);
request.getRequestDispatcher("customer/index.jsp").forward(request, response);
}
public void showCustomerByCid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showCustomerByCid....");
int cid=Integer.parseInt(request.getParameter("cid"));
Customer customer=customerService.showCustomerByCid(cid);
if(customer!=null)
{
request.setAttribute("customer",customer);
request.getRequestDispatcher("customer/edit.jsp").forward(request, response);
}
}
public void updateCustomer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateCustomer...");
try {
int cid=Integer.parseInt(request.getParameter("cid"));
String cname=request.getParameter("cname");
String csex=request.getParameter("csex");
int cage=Integer.parseInt(request.getParameter("cage"));
String cphone= request.getParameter("cphone");
String cemail= request.getParameter("cemail");
String caddress= request.getParameter("caddress");
Customer customer=new Customer();
customer.setCid(cid);
customer.setCname(cname);
admin.setAphone(aphone);
admin.setAaddress(aaddress);
boolean z = adminService.insertAdmin(admin);
if (z) {
response.sendRedirect("login.jsp");
} else {
request.setAttribute("error", "注册失败");
request.getRequestDispatcher("regist.jsp").forward(request, response);
}
}
// checkLogin
public void checkLogin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is checkLogin...");
String aname = request.getParameter("aname");
String apassword = request.getParameter("apassword");
Admin admin = adminService.checkLogin(aname, apassword);
System.out.println("========"+admin);
HttpSession session = request.getSession();
session.setAttribute("admin", admin);
request.getRequestDispatcher("index.jsp").forward(request, response);
}
public void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is logout...");
HttpSession session = request.getSession();
session.invalidate();
response.sendRedirect("login.jsp");
}
}
}
public void deleteOrderByOid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is deleteOrderByOid....");
int oid=Integer.parseInt(request.getParameter("oid"));
boolean z= orderService.deleteOrderByOid(oid);
System.out.println("z:"+z);
if(z)
{
showOrderByPage(request,response);
}
}
public void showOrder(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showOrder.....");
List<Order> order=orderService.showOrder();
request.setAttribute("order", order);
request.getRequestDispatcher("order/index.jsp").forward(request, response);
}
public void showOrderByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showOrderByPage.....");
String current_page=request.getParameter("current_page");
//先有鸡还是先有蛋。
int count_rows=orderService.counts();
PageTools pt=new PageTools(current_page, count_rows);
List<Order> order=orderService.showOrderByPage(pt);
//System.out.println(order);
request.setAttribute("pt", pt);
request.setAttribute("order",order);
request.getRequestDispatcher("order/index.jsp").forward(request, response);
}
public void showOrderByOid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showOrderByDid....");
int oid=Integer.parseInt(request.getParameter("oid"));
Order order=orderService.showOrderByOid(oid);
if(order!=null)
{
request.setAttribute("order",order);
String od =request.getParameter("prodate");
java.sql.Date odate=java.sql.Date.valueOf(od);
Order order=new Order();
order.setOid(oid);
order.setDid(did);
order.setOquantity(oquantity);
order.setOprice(oprice);
order.setCid(cid);
order.setOdate(odate);
//System.out.println(order);//检查。
boolean z=orderService.updateOrder(order);
if(z)
{
showOrderByPage(request,response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void updateOrderByOid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateOrderByOid....");
int oid=Integer.parseInt(request.getParameter("oid"));
Order order=orderService.showOrderByOid(oid);
if(order!=null)
{
request.setAttribute("order", order);
request.getRequestDispatcher("order/edit.jsp").forward(request, response);
}
}
}
public void updateOrderByOid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateOrderByOid....");
int oid=Integer.parseInt(request.getParameter("oid"));
Order order=orderService.showOrderByOid(oid);
if(order!=null)
{
request.setAttribute("order", order);
request.getRequestDispatcher("order/edit.jsp").forward(request, response);
}
}
}
/**
* Servlet implementation class SupplierServlet
*/
@WebServlet("/supplierServlet.do")
public class SupplierServlet extends BaseServlet {
private static final long serialVersionUID = 1L;
private SupplierService supplierService=new SupplierService();
public void insertSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is insertSupplier....");
try {
String sname=request.getParameter("sname");
String sphone=request.getParameter("sphone");
String saddress= request.getParameter("saddress");
Supplier supplier=new Supplier();
supplier.setSname(sname);
supplier.setSphone(sphone);
supplier.setSaddress(saddress);
System.out.println(supplier);//检查。
boolean z=supplierService.insertSupplier(supplier);
/**
* Servlet implementation class AdminServlet
*/
@WebServlet("/adminServlet.do")
public class AdminServlet extends BaseServlet {
private static final long serialVersionUID = 1L;
private AdminService adminService=new AdminService();
public void insertAdmin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is insertAdmin....");
try {
String aname=request.getParameter("aname");
String apassword=request.getParameter("apassword");
String aphone= request.getParameter("aphone");
String aaddress= request.getParameter("aaddress");
Admin admin=new Admin();
admin.setAname(aname);
admin.setApassword(apassword);
admin.setAphone(aphone);
admin.setAaddress(aaddress);
//System.out.println(admin);//检查。
boolean z=adminService.insertAdmin(admin);
if(z)
{
showAdminByPage(request,response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void deleteAdminByAid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is deleteAdminByAid....");
int aid=Integer.parseInt(request.getParameter("aid"));
boolean z= adminService.deleteAdminByAid(aid);
System.out.println("z:"+z);
{
showAdminByPage(request,response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void updateAdminByAid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateAdminByAid....");
int aid=Integer.parseInt(request.getParameter("aid"));
//System.out.println(did);
Admin admin=adminService.showAdminByAid(aid);
if(admin!=null)
{
request.setAttribute("admin", admin);
request.getRequestDispatcher("admin/edit.jsp").forward(request, response);
}
}
//注册
public void regist(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is regist...");
String aname = request.getParameter("aname");// 真实姓名
String apassword = request.getParameter("apassword");
String aphone = request.getParameter("aphone");
String aaddress = request.getParameter("aaddress");
Admin admin = new Admin();
admin.setAname(aname);
admin.setApassword(apassword);
admin.setAphone(aphone);
admin.setAaddress(aaddress);
boolean z = adminService.insertAdmin(admin);
if (z) {
response.sendRedirect("login.jsp");
} else {
request.setAttribute("error", "注册失败");
request.getRequestDispatcher("regist.jsp").forward(request, response);
}
}
try {
String sname=request.getParameter("sname");
String sphone=request.getParameter("sphone");
String saddress= request.getParameter("saddress");
Supplier supplier=new Supplier();
supplier.setSname(sname);
supplier.setSphone(sphone);
supplier.setSaddress(saddress);
System.out.println(supplier);//检查。
boolean z=supplierService.insertSupplier(supplier);
if(z)
{
showSupplierByPage(request,response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void deleteSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is deleteSupplierBySname....");
String sname=request.getParameter("sname");
boolean z= supplierService.deleteSupplierBySname(sname);
System.out.println("z:"+z);
if(z)
{
showSupplierByPage(request,response);
}
}
public void showSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplier.....");
List<Supplier> supplier=supplierService.showSupplier();
request.setAttribute("supplier", supplier);
request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
}
public void showSupplierByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplierByPage.....");
String current_page=request.getParameter("current_page");
//先有鸡还是先有蛋。
int count_rows=supplierService.counts();
PageTools pt=new PageTools(current_page, count_rows);
List<Supplier> supplier=supplierService.showSupplierByPage(pt);
request.setAttribute("pt", pt);
request.setAttribute("supplier",supplier);
request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
}
public void showSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplierBySname....");
String sname=request.getParameter("sname");
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void deleteSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is deleteSupplierBySname....");
String sname=request.getParameter("sname");
boolean z= supplierService.deleteSupplierBySname(sname);
System.out.println("z:"+z);
if(z)
{
showSupplierByPage(request,response);
}
}
public void showSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplier.....");
List<Supplier> supplier=supplierService.showSupplier();
request.setAttribute("supplier", supplier);
request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
}
public void showSupplierByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplierByPage.....");
String current_page=request.getParameter("current_page");
//先有鸡还是先有蛋。
int count_rows=supplierService.counts();
PageTools pt=new PageTools(current_page, count_rows);
List<Supplier> supplier=supplierService.showSupplierByPage(pt);
request.setAttribute("pt", pt);
request.setAttribute("supplier",supplier);
request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
}
public void showSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplierBySname....");
String sname=request.getParameter("sname");
Supplier supplier=supplierService.showSupplierBySname(sname);
if(supplier!=null)
{
request.setAttribute("supplier",supplier);
request.getRequestDispatcher("supplier/edit.jsp").forward(request, response);
}
}
public void updateSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateSupplier...");
try {
String sname=request.getParameter("sname");
String sphone=request.getParameter("sphone");
private static final long serialVersionUID = 1L;
private SupplierService supplierService=new SupplierService();
public void insertSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is insertSupplier....");
try {
String sname=request.getParameter("sname");
String sphone=request.getParameter("sphone");
String saddress= request.getParameter("saddress");
Supplier supplier=new Supplier();
supplier.setSname(sname);
supplier.setSphone(sphone);
supplier.setSaddress(saddress);
System.out.println(supplier);//检查。
boolean z=supplierService.insertSupplier(supplier);
if(z)
{
showSupplierByPage(request,response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void deleteSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is deleteSupplierBySname....");
String sname=request.getParameter("sname");
boolean z= supplierService.deleteSupplierBySname(sname);
System.out.println("z:"+z);
if(z)
{
showSupplierByPage(request,response);
}
}
public void showSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplier.....");
List<Supplier> supplier=supplierService.showSupplier();
request.setAttribute("supplier", supplier);
request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
}
public void showSupplierByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplierByPage.....");
String current_page=request.getParameter("current_page");
//先有鸡还是先有蛋。
int count_rows=supplierService.counts();
PageTools pt=new PageTools(current_page, count_rows);
List<Supplier> supplier=supplierService.showSupplierByPage(pt);
request.setAttribute("pt", pt);
int requantity=Integer.parseInt(request.getParameter("requantity"));
String sname= request.getParameter("sname");
String function= request.getParameter("function");
Drug drug=new Drug();
drug.setDid(did);
drug.setDname(dname);
drug.setDclass(dclass);
drug.setDprice(dprice);
drug.setProdate(prodate);
drug.setExdate(exdate);
drug.setRequantity(requantity);
drug.setSname(sname);
drug.setFunction(function);
System.out.println(drug);//检查。
boolean z=drugService.insertDrug(drug);
if(z)
{
showDrugByPage(request,response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void deleteDrugByDid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is deleteDrugByDid....");
String did=request.getParameter("did");
boolean z= drugService.deleteDrugByDid(did);
System.out.println("z:"+z);
if(z)
{
showDrugByPage(request,response);
}
}
public void showDrug(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showDrug.....");
List<Drug> drug=drugService.showDrug();
java.sql.Date exdate=java.sql.Date.valueOf(ex);
int requantity=Integer.parseInt(request.getParameter("requantity"));
String sname= request.getParameter("sname");
String function= request.getParameter("function");
Drug drug=new Drug();
drug.setDid(did);
drug.setDname(dname);
drug.setDclass(dclass);
drug.setDprice(dprice);
drug.setProdate(prodate);
drug.setExdate(exdate);
drug.setRequantity(requantity);
drug.setSname(sname);
drug.setFunction(function);
//System.out.println(drug);//检查。
boolean z=drugService.updateDrug(drug);
if(z)
{
showDrugByPage(request,response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void updateDrugByDid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateDrugByDid....");
String did=request.getParameter("did");
Drug drug=drugService.showDrugByDid(did);
if(drug!=null)
{
request.setAttribute("drug", drug);
request.getRequestDispatcher("drug/edit.jsp").forward(request, response);
}
}
}
public void updateDrug(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateDrug...");
try {
String did=request.getParameter("did");
String dname=request.getParameter("dname");
String dclass=request.getParameter("dclass");
String dprice=request.getParameter("dprice");
//SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
String pro =request.getParameter("prodate");
java.sql.Date prodate=java.sql.Date.valueOf(pro);
String ex =request.getParameter("exdate");
java.sql.Date exdate=java.sql.Date.valueOf(ex);
int requantity=Integer.parseInt(request.getParameter("requantity"));
String sname= request.getParameter("sname");
String function= request.getParameter("function");
Drug drug=new Drug();
drug.setDid(did);
drug.setDname(dname);
drug.setDclass(dclass);
drug.setDprice(dprice);
drug.setProdate(prodate);
drug.setExdate(exdate);
drug.setRequantity(requantity);
drug.setSname(sname);
drug.setFunction(function);
//System.out.println(drug);//检查。
boolean z=drugService.updateDrug(drug);
if(z)
{
showDrugByPage(request,response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void updateDrugByDid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateDrugByDid....");
String did=request.getParameter("did");
Drug drug=drugService.showDrugByDid(did);
List<Supplier> supplier=supplierService.showSupplier();
request.setAttribute("supplier", supplier);
request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
}
public void showSupplierByPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplierByPage.....");
String current_page=request.getParameter("current_page");
//先有鸡还是先有蛋。
int count_rows=supplierService.counts();
PageTools pt=new PageTools(current_page, count_rows);
List<Supplier> supplier=supplierService.showSupplierByPage(pt);
request.setAttribute("pt", pt);
request.setAttribute("supplier",supplier);
request.getRequestDispatcher("supplier/index.jsp").forward(request, response);
}
public void showSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showSupplierBySname....");
String sname=request.getParameter("sname");
Supplier supplier=supplierService.showSupplierBySname(sname);
if(supplier!=null)
{
request.setAttribute("supplier",supplier);
request.getRequestDispatcher("supplier/edit.jsp").forward(request, response);
}
}
public void updateSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateSupplier...");
try {
String sname=request.getParameter("sname");
String sphone=request.getParameter("sphone");
String saddress= request.getParameter("saddress");
Supplier supplier=new Supplier();
supplier.setSname(sname);
supplier.setSphone(sphone);
supplier.setSaddress(saddress);
//System.out.println(supplier);//检查。
boolean z=supplierService.updateSupplier(supplier);
if(z)
{
/**
* Servlet implementation class SupplierServlet
*/
@WebServlet("/supplierServlet.do")
public class SupplierServlet extends BaseServlet {
private static final long serialVersionUID = 1L;
private SupplierService supplierService=new SupplierService();
public void insertSupplier(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is insertSupplier....");
try {
String sname=request.getParameter("sname");
String sphone=request.getParameter("sphone");
String saddress= request.getParameter("saddress");
Supplier supplier=new Supplier();
supplier.setSname(sname);
supplier.setSphone(sphone);
supplier.setSaddress(saddress);
System.out.println(supplier);//检查。
boolean z=supplierService.insertSupplier(supplier);
if(z)
{
showSupplierByPage(request,response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void deleteSupplierBySname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("admin", admin);
request.getRequestDispatcher("admin/edit.jsp").forward(request, response);
}
}
//注册
public void regist(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is regist...");
String aname = request.getParameter("aname");// 真实姓名
String apassword = request.getParameter("apassword");
String aphone = request.getParameter("aphone");
String aaddress = request.getParameter("aaddress");
Admin admin = new Admin();
admin.setAname(aname);
admin.setApassword(apassword);
admin.setAphone(aphone);
admin.setAaddress(aaddress);
boolean z = adminService.insertAdmin(admin);
if (z) {
response.sendRedirect("login.jsp");
} else {
request.setAttribute("error", "注册失败");
request.getRequestDispatcher("regist.jsp").forward(request, response);
}
}
// checkLogin
public void checkLogin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is checkLogin...");
String aname = request.getParameter("aname");
String apassword = request.getParameter("apassword");
Admin admin = adminService.checkLogin(aname, apassword);
System.out.println("========"+admin);
HttpSession session = request.getSession();
session.setAttribute("admin", admin);
request.getRequestDispatcher("index.jsp").forward(request, response);
}
public void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is logout...");
HttpSession session = request.getSession();
session.invalidate();
response.sendRedirect("login.jsp");
}
}
request.setAttribute("drug",drug);
request.getRequestDispatcher("drug/index.jsp").forward(request, response);
}
public void showDrugByDid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is showDrugByDid....");
String did=request.getParameter("did");
Drug drug=drugService.showDrugByDid(did);
if(drug!=null)
{
request.setAttribute("drug",drug);
request.getRequestDispatcher("drug/index.jsp").forward(request, response);
}
}
public void updateDrug(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("this is updateDrug...");
try {
String did=request.getParameter("did");
String dname=request.getParameter("dname");
String dclass=request.getParameter("dclass");
String dprice=request.getParameter("dprice");
//SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
String pro =request.getParameter("prodate");
java.sql.Date prodate=java.sql.Date.valueOf(pro);
String ex =request.getParameter("exdate");
java.sql.Date exdate=java.sql.Date.valueOf(ex);
int requantity=Integer.parseInt(request.getParameter("requantity"));
String sname= request.getParameter("sname");
String function= request.getParameter("function");
Drug drug=new Drug();
drug.setDid(did);
drug.setDname(dname);
drug.setDclass(dclass);
drug.setDprice(dprice);
drug.setProdate(prodate);
drug.setExdate(exdate);
drug.setRequantity(requantity);
drug.setSname(sname);
drug.setFunction(function);
//System.out.println(drug);//检查。
boolean z=drugService.updateDrug(drug);
if(z)
{
showDrugByPage(request,response);