JavaWeb项目开发案例精粹-第6章报价管理系统-05Action层
0.
1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE struts PUBLIC 3 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 4 "http://struts.apache.org/dtds/struts-2.0.dtd"> 5 6 <struts> 7 <constant name="struts.enable.DynamicMethodInvocation" 8 value="false" /> 9 <constant name="struts.devMode" value="false" /> 10 <!-- 与spring集成 --> 11 <constant name="struts.objectFactory" value="spring" /> 12 <!-- 改变后缀名 --> 13 <constant name="struts.action.extension" value="do" /> 14 <!-- 配置国际化资源文件 --> 15 <constant name="struts.custom.i18n.resources" 16 value="globalMessages" /> 17 <!-- 处理编码问题 --> 18 <constant name="struts.i18n.encoding" value="GBK" /> 19 <!-- 当修改配置文件不需要重启服务,开发比较有用 --> 20 <constant name="struts.configuration.xml.reload" value="true" /> 21 <!-- 报表 --> 22 <!-- 23 <package name="lee" namespace="/" extends="jasperreports-default"> 24 <action name="jasper" class="jasperAction"> 25 <result name="success" type="jasper"> 26 <param name="location">report\jasper\order.jrxml</param> 27 <param name="format">HTML</param> 28 <param name="dataSource">order</param> 29 </result> 30 </action> 31 </package> 32 --> 33 <!-- 用户登录 --> 34 <package name="san" namespace="/" extends="struts-default"> 35 <action name="login" class="loginAction" > 36 <result name="success">/back_index.html</result> 37 <result name="input">/index.jsp</result> 38 </action> 39 </package> 40 <!-- 控制相关模块 --> 41 <package name="qing" namespace="/control" extends="struts-default"> 42 <interceptors><!--配置拦截器 --> 43 <interceptor name="loginIntercepter" 44 class="com.sanqing.intercepter.LoginIntercepter" /><!--配置登录判断拦截器--> 45 <interceptor-stack name="mydefault"><!--配置拦截器栈--> 46 <interceptor-ref name="defaultStack" /><!--Struts 2默认拦截器 --> 47 <interceptor-ref name="loginIntercepter" /><!--登录判断拦截器 --> 48 </interceptor-stack> 49 </interceptors> 50 <default-interceptor-ref name="mydefault" /><!--配置默认拦截器--> 51 <global-results> 52 <result name="pub_add_success">/share/pub_add_success.jsp</result> 53 <result name="pub_update_success">/share/pub_update_success.jsp</result> 54 <result name="pub_del_success">/share/pub_del_success.jsp</result> 55 <result name="input">/index.jsp</result> 56 </global-results> 57 <!-- 客户显示 --> 58 <action name="customer" class="customerAction"> 59 <result name="success"> 60 /customer/customer_list.jsp 61 </result> 62 </action> 63 <!-- 客户管理 --> 64 <action name="customermanage_*" class="customerManageAction" method="{1}"> 65 <result name="add">/customer/customer_add.jsp</result> 66 <result name="update">/customer/customer_update.jsp</result> 67 <result name="query">/customer/customer_query.jsp</result> 68 </action> 69 <!-- 产品类别显示 --> 70 <action name="producttype" class="productTypeAction"> 71 <result name="success"> 72 /product/producttype_list.jsp 73 </result> 74 </action> 75 <!-- 产品类别管理 --> 76 <action name="producttypemanage_*" class="productTypeManageAction" method="{1}"> 77 <result name="add">/product/producttype_add.jsp</result> 78 <result name="update">/product/producttype_update.jsp</result> 79 <result name="query">/product/producttype_query.jsp</result> 80 </action> 81 <!-- 产品显示 --> 82 <action name="product" class="productAction"> 83 <result name="success"> 84 /product/product_list.jsp 85 </result> 86 </action> 87 <!-- 产品管理 --> 88 <action name="productmanage_*" class="productManageAction" method="{1}"> 89 <result name="add">/product/product_add.jsp</result> 90 <result name="update">/product/product_update.jsp</result> 91 <result name="query">/product/product_query.jsp</result> 92 </action> 93 <!-- 订单显示 --> 94 <action name="order" class="orderAction"> 95 <result name="success"> 96 /order/order_list.jsp 97 </result> 98 </action> 99 <!-- 订单管理 --> 100 <action name="ordermanage_*" class="orderManageAction" method="{1}"> 101 <result name="add">/order/order_add.jsp</result> 102 <result name="update">/order/order_update.jsp</result> 103 <result name="query">/order/order_query.jsp</result> 104 </action> 105 <!-- 报价显示 --> 106 <action name="quotation" class="quotationAction"> 107 <result name="success"> 108 /quotation/quotation_list.jsp 109 </result> 110 </action> 111 <!-- 报价管理 --> 112 <action name="quotationmanage_*" class="quotationManageAction" method="{1}"> 113 <result name="add">/quotation/quotation_add.jsp</result> 114 <result name="update">/quotation/quotation_update.jsp</result> 115 <result name="query">/quotation/quotation_query.jsp</result> 116 </action> 117 <!-- 用户显示 --> 118 <action name="user" class="userAction"> 119 <result name="success"> 120 /user/user_list.jsp 121 </result> 122 </action> 123 <!-- 用户管理 --> 124 <action name="usermanage_*" class="userManageAction" method="{1}"> 125 <result name="add">/user/user_add.jsp</result> 126 <result name="update">/user/user_update.jsp</result> 127 <result name="query">/user/user_query.jsp</result> 128 </action> 129 </package> 130 </struts>
1.
1 package com.sanqing.action; 2 3 import com.opensymphony.xwork2.ActionSupport; 4 /** 5 * 基本的action 6 */ 7 public class BaseAction extends ActionSupport { 8 public Integer page; //当前页信息 9 public String query; //是否为条件查询 10 public Integer getPage() {//获得当前页信息 11 return page = (page==null || page<1)? 1 : page; 12 } 13 public void setPage(Integer page) {//设置当前页信息 14 this.page = page; 15 } 16 public String getQuery() {//获得query信息 17 return query; 18 } 19 public void setQuery(String query) {//设置query信息 20 this.query = query; 21 } 22 }
2.
1 package com.sanqing.action; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 import javax.annotation.Resource; 7 import javax.servlet.http.HttpServletRequest; 8 9 import org.apache.struts2.ServletActionContext; 10 import org.springframework.context.annotation.Scope; 11 import org.springframework.stereotype.Controller; 12 13 import com.sanqing.po.Customer; 14 import com.sanqing.service.CustomerService; 15 import com.sanqing.util.PageView; 16 17 /** 18 * 客户显示action 19 */ 20 @Controller("customerAction") 21 @Scope("prototype") 22 public class CustomerAction extends BaseAction{ 23 @Resource 24 private CustomerService customerService;//注入客户业务组件 25 private String customerNO; //客户编号 26 private String customerName; //客户名称 27 private String phone; //客户电话 28 private String address; //客户地址 29 private String relationman; //客户联系人 30 private String otherInfo; //其他 31 @Override 32 public String execute() throws Exception { 33 PageView<Customer> pageView = 34 new PageView<Customer>(5, getPage());//设置分页信息,每页显示5条记录 35 StringBuffer jpql = new StringBuffer(""); //初始化条件查询语句 36 List<Object> params = new ArrayList<Object>(); //初始化查询参数列表 37 if("true".equals(getQuery())) { //是否为条件查询 38 if(customerNO!=null && !"".equals(customerNO.trim())) {//根据客户编号进行查询 39 if(params.size()>0) jpql.append(" and "); 40 jpql.append(" o.customerNO like ?").append(params.size()+1); 41 params.add("%"+ customerNO +"%"); 42 } 43 if(customerName!=null && !"".equals(customerName.trim())) {//根据客户名称查询 44 if(params.size()>0) jpql.append(" and "); 45 jpql.append(" o.customerName like ?").append(params.size()+1); 46 params.add("%"+customerName+"%"); 47 } 48 if(phone!=null && !"".equals(phone.trim())) {//根据电话号码查询 49 if(params.size()>0) jpql.append(" and "); 50 jpql.append(" o.phone like ?").append(params.size()+1); 51 params.add("%"+phone+"%"); 52 } 53 if(address!=null && !"".equals(address.trim())) {//根据地址查询 54 if(params.size()>0) jpql.append(" and "); 55 jpql.append(" o.address like ?").append(params.size()+1); 56 params.add("%"+address+"%"); 57 } 58 if(relationman!=null && !"".equals(relationman.trim())) {//根据联系人查询 59 if(params.size()>0) jpql.append(" and "); 60 jpql.append(" o.relationman like ?").append(params.size()+1); 61 params.add("%"+relationman+"%"); 62 } 63 if(otherInfo!=null && !"".equals(otherInfo.trim())) {//根据其他信息查询 64 if(params.size()>0) jpql.append(" and "); 65 jpql.append(" o.otherInfo like ?").append(params.size()+1); 66 params.add("%"+otherInfo+"%"); 67 } 68 pageView.setQueryResult(customerService.getScrollData( 69 pageView.getFirstResult(), pageView.getMaxresult(), 70 jpql.toString(), params.toArray()));//按条件查询 71 }else{ 72 pageView.setQueryResult(customerService.getScrollData 73 (pageView.getFirstResult(), pageView.getMaxresult()));//查询所有记录 74 } 75 HttpServletRequest request = ServletActionContext.getRequest();//获得request对象 76 request.setAttribute("pageView", pageView);//保存到request范围 77 return this.SUCCESS; 78 } 79 80 public String getCustomerNO() { 81 return customerNO; 82 } 83 public void setCustomerNO(String customerNO) { 84 this.customerNO = customerNO; 85 } 86 public String getCustomerName() { 87 return customerName; 88 } 89 public void setCustomerName(String customerName) { 90 this.customerName = customerName; 91 } 92 public String getPhone() { 93 return phone; 94 } 95 public void setPhone(String phone) { 96 this.phone = phone; 97 } 98 public String getAddress() { 99 return address; 100 } 101 public void setAddress(String address) { 102 this.address = address; 103 } 104 public String getRelationman() { 105 return relationman; 106 } 107 public void setRelationman(String relationman) { 108 this.relationman = relationman; 109 } 110 111 public String getOtherInfo() { 112 return otherInfo; 113 } 114 115 public void setOtherInfo(String otherInfo) { 116 this.otherInfo = otherInfo; 117 } 118 }
3.
1 package com.sanqing.action; 2 3 import javax.annotation.Resource; 4 import javax.servlet.http.HttpServletRequest; 5 6 import org.apache.struts2.ServletActionContext; 7 import org.springframework.context.annotation.Scope; 8 import org.springframework.stereotype.Controller; 9 10 import com.sanqing.po.Customer; 11 import com.sanqing.service.CustomerService; 12 /** 13 * 客户管理action 14 */ 15 @Controller("customerManageAction") 16 @Scope("prototype") 17 public class CustomerManageAction extends BaseAction { 18 @Resource 19 private CustomerService customerService;//注入客户业务逻辑组件 20 private String customerNO; //客户编号 21 private String customerName; //客户名称 22 private String phone; //客户电话 23 private String address; //客户地址 24 private String relationman; //客户联系人 25 private String otherInfo; //其他信息 26 public String addUI() { //新增客户输入界面 27 return "add"; 28 } 29 public String add() { //新增客户方法 30 Customer customer = new Customer(); 31 customer.setAddress(address); 32 customer.setCustomerNO(customerNO); 33 customer.setCustomerName(customerName); 34 customer.setOtherInfo(otherInfo); 35 customer.setPhone(phone); 36 customer.setRelationman(relationman); 37 customerService.save(customer); 38 return "pub_add_success"; 39 } 40 public String updateUI() { //该方法用来跳转到客户信息更新表单 41 Customer customer = customerService.find(customerNO);//查询该客户编号对应的客户 42 HttpServletRequest request = ServletActionContext.getRequest();//获得request对象 43 request.setAttribute("customer", customer);//将客户信息保存在request范围 44 return "update";//跳转到客户信息更新表单页 45 } 46 47 public String update() { 48 Customer customer = new Customer(); 49 customer.setAddress(address); 50 customer.setCustomerNO(customerNO); 51 customer.setCustomerName(customerName); 52 customer.setOtherInfo(otherInfo); 53 customer.setPhone(phone); 54 customer.setRelationman(relationman); 55 customerService.update(customer);//更新客户信息 56 return "pub_update_success";//跳转到更新成功页面 57 } 58 /** 59 * 删除客户 60 * @return 61 */ 62 public String del() { //删除客户信息 63 customerService.delete(customerNO);//根据客户编号删除客户 64 return "pub_del_success";//跳转到删除成功页 65 } 66 /** 67 * 查询客户信息 68 * @return 69 */ 70 public String query() { 71 return "query"; 72 } 73 public String getCustomerNO() { 74 return customerNO; 75 } 76 public void setCustomerNO(String customerNO) { 77 this.customerNO = customerNO; 78 } 79 public String getCustomerName() { 80 return customerName; 81 } 82 public void setCustomerName(String customerName) { 83 this.customerName = customerName; 84 } 85 public String getPhone() { 86 return phone; 87 } 88 public void setPhone(String phone) { 89 this.phone = phone; 90 } 91 public String getAddress() { 92 return address; 93 } 94 public void setAddress(String address) { 95 this.address = address; 96 } 97 public String getRelationman() { 98 return relationman; 99 } 100 public void setRelationman(String relationman) { 101 this.relationman = relationman; 102 } 103 public String getOtherInfo() { 104 return otherInfo; 105 } 106 public void setOtherInfo(String otherInfo) { 107 this.otherInfo = otherInfo; 108 } 109 110 111 }
4.
1 package com.sanqing.action; 2 3 import java.util.Map; 4 5 import javax.annotation.Resource; 6 7 import org.springframework.context.annotation.Scope; 8 import org.springframework.stereotype.Controller; 9 10 import com.opensymphony.xwork2.ActionContext; 11 import com.opensymphony.xwork2.ActionSupport; 12 import com.sanqing.service.UserService; 13 /** 14 * 用户登录 15 */ 16 @Controller("loginAction") 17 @Scope("prototype") 18 public class LoginAction extends ActionSupport { 19 20 @Resource 21 private UserService userService ; 22 private String username ; 23 private String password ; 24 @Override 25 public String execute() throws Exception { 26 if(!userService.login(username, password)) { 27 return this.INPUT; 28 }else{ 29 Map session = ActionContext.getContext().getSession(); 30 session.put("user", userService.find(username)); 31 } 32 return this.SUCCESS; 33 } 34 35 public String getUsername() { 36 return username; 37 } 38 public void setUsername(String username) { 39 this.username = username; 40 } 41 public String getPassword() { 42 return password; 43 } 44 public void setPassword(String password) { 45 this.password = password; 46 } 47 }
5.
1 package com.sanqing.action; 2 3 import java.util.ArrayList; 4 import java.util.Date; 5 import java.util.List; 6 7 import javax.annotation.Resource; 8 import javax.servlet.http.HttpServletRequest; 9 10 import org.apache.struts2.ServletActionContext; 11 import org.springframework.context.annotation.Scope; 12 import org.springframework.stereotype.Controller; 13 14 import com.sanqing.po.Customer; 15 import com.sanqing.po.Order; 16 import com.sanqing.po.Product; 17 import com.sanqing.service.OrderService; 18 import com.sanqing.util.PageView; 19 20 @Controller("orderAction") 21 @Scope("prototype") 22 public class OrderAction extends BaseAction { 23 24 @Resource 25 private OrderService orderService; 26 /* 订单编码 */ 27 private String orderNO; 28 /* 客户名称 */ 29 private Customer customer; 30 private String customerName; 31 /* 产品名称 */ 32 private Product product; 33 private String productname; 34 /* 产品数量 */ 35 private int quantity; 36 /* 订单的时间 */ 37 private Date ordetTime; 38 /* 其他信息*/ 39 private String otherInfo; 40 @Override 41 public String execute() throws Exception { 42 HttpServletRequest request = ServletActionContext.getRequest(); 43 PageView<Order> pageView = new PageView<Order>(5, getPage()); 44 StringBuffer jpql = new StringBuffer(""); 45 List<Object> params = new ArrayList<Object>(); 46 if("true".equals(getQuery())) { 47 if(orderNO!=null && !"".equals(orderNO)) { 48 if(params.size()>0) jpql.append(" and "); 49 jpql.append(" o.orderNO = ?").append(params.size()+1); 50 params.add(orderNO); 51 } 52 if(customerName!=null && !"".equals(customerName)) { 53 if(params.size()>0) jpql.append(" and "); 54 jpql.append(" o.customer.customerName like ?").append(params.size()+1); 55 params.add("%"+customerName+"%"); 56 } 57 if(productname!=null && !"".equals(productname)) { 58 if(params.size()>0) jpql.append(" and "); 59 jpql.append(" o.product.productname like ?").append(params.size()+1); 60 params.add("%"+productname+"%"); 61 } 62 if(quantity>0) { 63 if(params.size()>0) jpql.append(" and "); 64 jpql.append(" o.quantity = ?").append(params.size()+1); 65 params.add(quantity); 66 } 67 if(otherInfo!=null && !"".equals(otherInfo)) { 68 if(params.size()>0) jpql.append(" and "); 69 jpql.append(" o.otherInfo like ?").append(params.size()+1); 70 params.add("%"+otherInfo+"%"); 71 } 72 pageView.setQueryResult(orderService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult(), jpql.toString(), params.toArray())); 73 }else{ 74 pageView.setQueryResult(orderService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult())); 75 } 76 request.setAttribute("pageView", pageView); 77 return this.SUCCESS; 78 } 79 public String getOrderNO() { 80 return orderNO; 81 } 82 public void setOrderNO(String orderNO) { 83 this.orderNO = orderNO; 84 } 85 public Customer getCustomer() { 86 return customer; 87 } 88 public void setCustomer(Customer customer) { 89 this.customer = customer; 90 } 91 public Product getProduct() { 92 return product; 93 } 94 public void setProduct(Product product) { 95 this.product = product; 96 } 97 public int getQuantity() { 98 return quantity; 99 } 100 public void setQuantity(int quantity) { 101 this.quantity = quantity; 102 } 103 public Date getOrdetTime() { 104 return ordetTime; 105 } 106 public void setOrdetTime(Date ordetTime) { 107 this.ordetTime = ordetTime; 108 } 109 public String getOtherInfo() { 110 return otherInfo; 111 } 112 public void setOtherInfo(String otherInfo) { 113 this.otherInfo = otherInfo; 114 } 115 public String getProductname() { 116 return productname; 117 } 118 public void setProductname(String productname) { 119 this.productname = productname; 120 } 121 public String getCustomerName() { 122 return customerName; 123 } 124 public void setCustomerName(String customerName) { 125 this.customerName = customerName; 126 } 127 128 129 }
6.
1 package com.sanqing.action; 2 3 import java.util.Date; 4 import java.util.List; 5 6 import javax.annotation.Resource; 7 import javax.servlet.http.HttpServletRequest; 8 9 import org.apache.struts2.ServletActionContext; 10 import org.springframework.context.annotation.Scope; 11 import org.springframework.stereotype.Controller; 12 13 import com.sanqing.po.Customer; 14 import com.sanqing.po.Order; 15 import com.sanqing.po.Product; 16 import com.sanqing.service.CustomerService; 17 import com.sanqing.service.OrderService; 18 import com.sanqing.service.ProductService; 19 20 @Controller("orderManageAction") 21 @Scope("prototype") 22 public class OrderManageAction extends BaseAction { 23 24 @Resource 25 private OrderService orderService; 26 @Resource 27 private CustomerService customerService; 28 @Resource 29 private ProductService productService; 30 31 /* 订单编码 */ 32 private String orderNO; 33 /* 客户名称 */ 34 private Customer customer; 35 /* 产品名称 */ 36 private Product product; 37 /* 产品数量 */ 38 private int quantity; 39 /* 订单的时间 */ 40 private Date orderTime; 41 /* 其他信息*/ 42 private String otherInfo; 43 44 /** 45 * 添加订单输入界面 46 * @return 47 */ 48 public String addUI() { 49 HttpServletRequest request = ServletActionContext.getRequest(); 50 List<Customer> customers = customerService.getScrollData().getResultlist(); 51 List<Product> products = productService.getScrollData().getResultlist(); 52 request.setAttribute("customers", customers); 53 request.setAttribute("products", products); 54 return "add"; 55 } 56 /** 57 * 添加订单 58 * @return 59 */ 60 public String add() { 61 Order order = new Order(); 62 order.setCustomer(customer); 63 order.setOrderNO(orderNO); 64 order.setOrderTime(orderTime); 65 order.setOtherInfo(otherInfo); 66 order.setProduct(product); 67 order.setQuantity(quantity); 68 orderService.save(order); 69 return "pub_add_success"; 70 } 71 /** 72 * 修改订单输入界面 73 * @return 74 */ 75 public String updateUI() { 76 HttpServletRequest request = ServletActionContext.getRequest(); 77 List<Customer> customers = customerService.getScrollData().getResultlist(); 78 List<Product> products = productService.getScrollData().getResultlist(); 79 Order order = orderService.find(orderNO); 80 request.setAttribute("customers", customers); 81 request.setAttribute("products", products); 82 request.setAttribute("order", order); 83 return "update"; 84 } 85 /** 86 * 修改订单 87 * @return 88 */ 89 public String update() { 90 Order order = new Order(); 91 order.setCustomer(customer); 92 order.setOrderNO(orderNO); 93 order.setOrderTime(orderTime); 94 order.setOtherInfo(otherInfo); 95 order.setProduct(product); 96 order.setQuantity(quantity); 97 orderService.update(order); 98 return "pub_update_success"; 99 } 100 /** 101 * 删除订单 102 * @return 103 */ 104 public String del() { 105 orderService.delete(orderNO); 106 return "pub_del_success"; 107 } 108 /** 109 * 查询订单 110 * @return 111 */ 112 public String query() { 113 HttpServletRequest request = ServletActionContext.getRequest(); 114 List<Customer> customers = customerService.getScrollData().getResultlist(); 115 List<Product> products = productService.getScrollData().getResultlist(); 116 request.setAttribute("customers", customers); 117 request.setAttribute("products", products); 118 return "query"; 119 } 120 121 public String getOrderNO() { 122 return orderNO; 123 } 124 public void setOrderNO(String orderNO) { 125 this.orderNO = orderNO; 126 } 127 public Customer getCustomer() { 128 return customer; 129 } 130 public void setCustomer(Customer customer) { 131 this.customer = customer; 132 } 133 public Product getProduct() { 134 return product; 135 } 136 public void setProduct(Product product) { 137 this.product = product; 138 } 139 public int getQuantity() { 140 return quantity; 141 } 142 public void setQuantity(int quantity) { 143 this.quantity = quantity; 144 } 145 public Date getOrderTime() { 146 return orderTime; 147 } 148 public void setOrderTime(Date orderTime) { 149 this.orderTime = orderTime; 150 } 151 public String getOtherInfo() { 152 return otherInfo; 153 } 154 public void setOtherInfo(String otherInfo) { 155 this.otherInfo = otherInfo; 156 } 157 }
7.
1 package com.sanqing.action; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 import javax.annotation.Resource; 7 import javax.servlet.http.HttpServletRequest; 8 9 import org.apache.struts2.ServletActionContext; 10 import org.springframework.context.annotation.Scope; 11 import org.springframework.stereotype.Controller; 12 13 import com.sanqing.po.Product; 14 import com.sanqing.service.ProductService; 15 import com.sanqing.util.PageView; 16 /** 17 * 显示产品 18 */ 19 @Controller("productAction") 20 @Scope("prototype") 21 public class ProductAction extends BaseAction { 22 @Resource 23 private ProductService productService; 24 /* 产品编号 */ 25 private String productNO; 26 // 产品类型编号 27 private String producttypeNO; 28 //产品类型名称 29 private String producttypeName; 30 /* 产品名称 */ 31 private String productName; 32 /* 产品所在区域 */ 33 private String productArea; 34 /* 产品所有者 */ 35 private String productOwner; 36 /* 产品单位 */ 37 private String unit; 38 /* 产品价格 */ 39 private double price; 40 /* 产品数量*/ 41 private int quantity; 42 /* 其他信息 */ 43 private String otherInfo; 44 45 @Override 46 public String execute() throws Exception { 47 PageView<Product> pageView = new PageView<Product>(5, getPage()); 48 StringBuffer jpql = new StringBuffer(""); 49 List<Object> params = new ArrayList<Object>(); 50 if("true".equals(getQuery())) { 51 if(productNO!=null && !"".equals(productNO.trim())) { 52 if(params.size()>0) jpql.append(" and "); 53 jpql.append(" o.productNO=?").append(params.size()+1); 54 params.add(productNO); 55 } 56 if(producttypeName!=null && !"".equals(producttypeName.trim())) { 57 if(params.size()>0)jpql.append(" and "); 58 jpql.append(" o.productType.producttypeName like ?").append(params.size()+1); 59 params.add(producttypeName); 60 } 61 if(productName!=null && !"".equals(productName.trim())) { 62 if(params.size()>0)jpql.append(" and "); 63 jpql.append(" o.productName like ?").append(params.size()+1); 64 params.add(productName); 65 } 66 if(productArea!=null && !"".equals(productArea.trim())) { 67 if(params.size()>0)jpql.append(" and "); 68 jpql.append(" o.productArea like ?").append(params.size()+1); 69 params.add(productArea); 70 } 71 if(productOwner!=null && !"".equals(productOwner.trim())) { 72 if(params.size()>0)jpql.append(" and "); 73 jpql.append(" o.productOwner like ?").append(params.size()+1); 74 params.add(productOwner); 75 } 76 if(unit!=null && !"".equals(unit.trim())) { 77 if(params.size()>0)jpql.append(" and "); 78 jpql.append(" o.unit like ?").append(params.size()+1); 79 params.add(unit); 80 } 81 if(price>0) { 82 if(params.size()>0)jpql.append(" and "); 83 jpql.append(" o.price=?").append(params.size()+1); 84 params.add(price); 85 } 86 if(quantity>0) { 87 if(params.size()>0)jpql.append(" and "); 88 jpql.append(" o.quantity=?").append(params.size()+1); 89 params.add(quantity); 90 } 91 if(otherInfo!=null && !"".equals(otherInfo.trim())) { 92 if(params.size()>0)jpql.append(" and "); 93 jpql.append(" o.otherInfo like ?").append(params.size()+1); 94 params.add(otherInfo); 95 } 96 pageView.setQueryResult(productService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult(),jpql.toString(), params.toArray())); 97 }else{ 98 pageView.setQueryResult(productService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult())); 99 } 100 HttpServletRequest request = ServletActionContext.getRequest(); 101 request.setAttribute("pageView", pageView); 102 return this.SUCCESS; 103 } 104 public String getProductNO() { 105 return productNO; 106 } 107 public void setProductNO(String productNO) { 108 this.productNO = productNO; 109 } 110 public String getProductName() { 111 return productName; 112 } 113 public void setProductName(String productName) { 114 this.productName = productName; 115 } 116 public String getProductArea() { 117 return productArea; 118 } 119 public void setProductArea(String productArea) { 120 this.productArea = productArea; 121 } 122 public String getProductOwner() { 123 return productOwner; 124 } 125 public void setProductOwner(String productOwner) { 126 this.productOwner = productOwner; 127 } 128 public String getUnit() { 129 return unit; 130 } 131 public void setUnit(String unit) { 132 this.unit = unit; 133 } 134 public double getPrice() { 135 return price; 136 } 137 public void setPrice(double price) { 138 this.price = price; 139 } 140 public int getQuantity() { 141 return quantity; 142 } 143 public void setQuantity(int quantity) { 144 this.quantity = quantity; 145 } 146 public String getOtherInfo() { 147 return otherInfo; 148 } 149 public void setOtherInfo(String otherInfo) { 150 this.otherInfo = otherInfo; 151 } 152 public String getProducttypeNO() { 153 return producttypeNO; 154 } 155 public void setProducttypeNO(String producttypeNO) { 156 this.producttypeNO = producttypeNO; 157 } 158 public String getProducttypeName() { 159 return producttypeName; 160 } 161 public void setProducttypeName(String producttypeName) { 162 this.producttypeName = producttypeName; 163 } 164 165 }
8.
1 package com.sanqing.action; 2 3 import java.util.List; 4 5 import javax.annotation.Resource; 6 import javax.servlet.http.HttpServletRequest; 7 8 import org.apache.struts2.ServletActionContext; 9 import org.springframework.context.annotation.Scope; 10 import org.springframework.stereotype.Controller; 11 12 import com.sanqing.po.Product; 13 import com.sanqing.po.ProductType; 14 import com.sanqing.service.ProductService; 15 import com.sanqing.service.ProductTypeService; 16 /** 17 * 产品管理 18 */ 19 @Controller("productManageAction") 20 @Scope("prototype") 21 public class ProductManageAction extends BaseAction { 22 23 @Resource 24 private ProductService productService; 25 @Resource 26 private ProductTypeService productTypeService; 27 28 /* 产品编号 */ 29 private String productNO; 30 // 产品类型编号 31 private String producttypeNO; 32 /* 产品名称 */ 33 private String productName; 34 /* 产品所在区域 */ 35 private String producingArea; 36 /* 产品所有者 */ 37 private String productOwner; 38 /* 产品单位 */ 39 private String unit; 40 /* 产品价格 */ 41 private double price; 42 /* 产品数量*/ 43 private int quantity; 44 /* 其他信息 */ 45 private String otherInfo; 46 /** 47 * 添加产品输入界面 48 * @return 49 */ 50 public String addUI() { 51 HttpServletRequest request = ServletActionContext.getRequest(); 52 List<ProductType> producttypes = productTypeService.getScrollData().getResultlist(); 53 request.setAttribute("producttypes", producttypes); 54 return "add"; 55 } 56 /** 57 * 添加产品 58 * @return 59 */ 60 public String add() { 61 Product product = new Product(); 62 product.setProductNO(productNO); 63 product.setProductType(new ProductType(producttypeNO)); 64 product.setOtherInfo(otherInfo); 65 product.setPrice(price); 66 product.setProducingArea(producingArea); 67 product.setProductName(productName); 68 product.setProductOwner(productOwner); 69 product.setQuantity(quantity); 70 product.setUnit(unit); 71 productService.save(product); 72 return "pub_add_success"; 73 } 74 /** 75 * 修改产品输入界面 76 * @return 77 */ 78 public String updateUI() { 79 Product product = productService.find(productNO); 80 HttpServletRequest request = ServletActionContext.getRequest(); 81 request.setAttribute("product", product); 82 List<ProductType> producttypes = productTypeService.getScrollData().getResultlist(); 83 request.setAttribute("producttypes", producttypes); 84 return "update"; 85 } 86 /** 87 * 修改产品 88 * @return 89 */ 90 public String update() { 91 Product product = new Product(); 92 product.setProductNO(productNO); 93 product.setProductType(new ProductType(producttypeNO)); 94 product.setOtherInfo(otherInfo); 95 product.setPrice(price); 96 product.setProducingArea(producingArea); 97 product.setProductName(productName); 98 product.setProductOwner(productOwner); 99 product.setQuantity(quantity); 100 product.setUnit(unit); 101 productService.update(product); 102 return "pub_update_success"; 103 } 104 /** 105 * 删除产品 106 * @return 107 */ 108 public String del() { 109 productService.delete(productNO); 110 return "pub_del_success"; 111 } 112 /** 113 * 产品查询 114 * @return 115 */ 116 public String query() { 117 return "query"; 118 } 119 public String getProductNO() { 120 return productNO; 121 } 122 public void setProductNO(String productNO) { 123 this.productNO = productNO; 124 } 125 public String getProducttypeNO() { 126 return producttypeNO; 127 } 128 public void setProducttypeNO(String producttypeNO) { 129 this.producttypeNO = producttypeNO; 130 } 131 public String getProductName() { 132 return productName; 133 } 134 public void setProductName(String productName) { 135 this.productName = productName; 136 } 137 public String getProducingArea() { 138 return producingArea; 139 } 140 public void setProducingArea(String producingArea) { 141 this.producingArea = producingArea; 142 } 143 public String getProductOwner() { 144 return productOwner; 145 } 146 public void setProductOwner(String productOwner) { 147 this.productOwner = productOwner; 148 } 149 public String getUnit() { 150 return unit; 151 } 152 public void setUnit(String unit) { 153 this.unit = unit; 154 } 155 public double getPrice() { 156 return price; 157 } 158 public void setPrice(double price) { 159 this.price = price; 160 } 161 public int getQuantity() { 162 return quantity; 163 } 164 public void setQuantity(int quantity) { 165 this.quantity = quantity; 166 } 167 public String getOtherInfo() { 168 return otherInfo; 169 } 170 public void setOtherInfo(String otherInfo) { 171 this.otherInfo = otherInfo; 172 } 173 174 }
9.
1 package com.sanqing.action; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 import javax.annotation.Resource; 7 import javax.servlet.http.HttpServletRequest; 8 9 import org.apache.struts2.ServletActionContext; 10 import org.springframework.context.annotation.Scope; 11 import org.springframework.stereotype.Controller; 12 13 import com.sanqing.po.ProductType; 14 import com.sanqing.service.ProductTypeService; 15 import com.sanqing.util.PageView; 16 /** 17 * 产品类别显示 18 */ 19 @Controller("productTypeAction") 20 @Scope("prototype") 21 public class ProductTypeAction extends BaseAction { 22 23 @Resource 24 private ProductTypeService productTypeService; 25 26 // 产品类型编号 27 private String producttypeNO; 28 // 产品类型名称 29 private String producttypeName; 30 31 @Override 32 public String execute() throws Exception { 33 PageView<ProductType> pageView = new PageView<ProductType>(5, getPage()); 34 StringBuffer jpql = new StringBuffer(""); 35 List<Object> params = new ArrayList<Object>(); 36 if("true".equals(getQuery())) { 37 if(producttypeName!=null && !"".equals(producttypeName.trim())) { 38 if(params.size()>0) jpql.append(" and "); 39 jpql.append(" o.producttypeName like ?").append(params.size()+1); 40 params.add("%"+producttypeName+"%"); 41 } 42 if(producttypeNO!=null && !"".equals(producttypeNO.trim())) { 43 if(params.size()>0) jpql.append(" and "); 44 jpql.append(" o.producttypeNO like ?").append(params.size()+1); 45 params.add("%"+producttypeNO+"%"); 46 } 47 pageView.setQueryResult(productTypeService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult(), jpql.toString(), params.toArray())); 48 }else{ 49 pageView.setQueryResult(productTypeService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult())); 50 } 51 HttpServletRequest request = ServletActionContext.getRequest(); 52 request.setAttribute("pageView", pageView); 53 return this.SUCCESS; 54 } 55 public String getProducttypeNO() { 56 return producttypeNO; 57 } 58 public void setProducttypeNO(String producttypeNO) { 59 this.producttypeNO = producttypeNO; 60 } 61 public String getProducttypeName() { 62 return producttypeName; 63 } 64 public void setProducttypeName(String producttypeName) { 65 this.producttypeName = producttypeName; 66 } 67 }
10.
1 package com.sanqing.action; 2 3 import javax.annotation.Resource; 4 import javax.servlet.http.HttpServletRequest; 5 6 import org.apache.struts2.ServletActionContext; 7 import org.springframework.context.annotation.Scope; 8 import org.springframework.stereotype.Controller; 9 10 import com.sanqing.po.ProductType; 11 import com.sanqing.service.ProductTypeService; 12 13 @Controller("productTypeManageAction") 14 @Scope("prototype") 15 public class ProductTypeManageAction extends BaseAction { 16 17 @Resource 18 private ProductTypeService productTypeService ; 19 // 产品类型编号 20 private String producttypeNO; 21 // 产品类型名称 22 private String producttypeName; 23 /** 24 * 添加产品类别输入界面 25 * @return 26 */ 27 public String addUI() { 28 return "add"; 29 } 30 /** 31 * 添加产品类别 32 * @return 33 */ 34 public String add() { 35 ProductType productType = new ProductType(); 36 productType.setProducttypeNO(producttypeNO); 37 productType.setProducttypeName(producttypeName); 38 productTypeService.save(productType); 39 return "pub_add_success"; 40 } 41 /** 42 * 修改产品类别输入界面 43 * @return 44 */ 45 public String updateUI() { 46 ProductType productType = productTypeService.find(producttypeNO); 47 HttpServletRequest request = ServletActionContext.getRequest(); 48 request.setAttribute("productType", productType); 49 return "update"; 50 } 51 /** 52 * 修改产品类别 53 * @return 54 */ 55 public String update() { 56 ProductType productType = new ProductType(); 57 productType.setProducttypeNO(producttypeNO); 58 productType.setProducttypeName(producttypeName); 59 productTypeService.update(productType); 60 return "pub_update_success"; 61 } 62 /** 63 * 删除产品类别 64 * @return 65 */ 66 public String del() { 67 productTypeService.delete(producttypeNO); 68 return "pub_del_success"; 69 } 70 /** 71 * 产品类别查询 72 * @return 73 */ 74 public String query() { 75 return "query"; 76 } 77 public String getProducttypeNO() { 78 return producttypeNO; 79 } 80 public void setProducttypeNO(String producttypeNO) { 81 this.producttypeNO = producttypeNO; 82 } 83 public String getProducttypeName() { 84 return producttypeName; 85 } 86 public void setProducttypeName(String producttypeName) { 87 this.producttypeName = producttypeName; 88 } 89 }
11.
1 package com.sanqing.action; 2 3 import java.util.ArrayList; 4 import java.util.Date; 5 import java.util.List; 6 7 import javax.annotation.Resource; 8 import javax.servlet.http.HttpServletRequest; 9 10 import org.apache.struts2.ServletActionContext; 11 import org.springframework.context.annotation.Scope; 12 import org.springframework.stereotype.Controller; 13 14 import com.sanqing.po.Customer; 15 import com.sanqing.po.Product; 16 import com.sanqing.po.Quotation; 17 import com.sanqing.service.QuotationService; 18 import com.sanqing.util.PageView; 19 20 @Controller("quotationAction") 21 @Scope("prototype") 22 public class QuotationAction extends BaseAction { 23 @Resource 24 private QuotationService quotationService; //报价业务逻辑组件 25 // 报价编号 26 private String quotationNO; 27 // 报价人 28 private String quotationMan; 29 // 报价时间 30 private Date quotationtime; 31 // 其他 32 private String otherInfo; 33 //产品 34 private Product product ; 35 private String productName; 36 //客户 37 private Customer customer; 38 private String customerName; 39 40 41 42 @Override 43 public String execute() throws Exception { 44 PageView<Quotation> pageView = 45 new PageView<Quotation>(5, getPage());//设置分页信息 46 StringBuffer jpql = new StringBuffer("");//初始化条件查询语句 47 List<Object> params = new ArrayList<Object>();//初始化查询参数 48 if("true".equals(getQuery())) { //按条件查询 49 if(quotationNO!=null && !"".equals(quotationNO)) {//根据报价编号进行查询 50 if(params.size()>0) jpql.append(" and "); 51 jpql.append(" o.quotationNO = ?").append(params.size()+1); 52 params.add(quotationNO); 53 } 54 if(quotationMan!=null && !"".equals(quotationMan)) {//根据报价人进行查询 55 if(params.size()>0) jpql.append(" and "); 56 jpql.append(" o.quotationMan like ?").append(params.size()+1); 57 params.add(quotationMan); 58 } 59 if(otherInfo!=null && !"".equals(otherInfo)) {//根据其他信息进行查询 60 if(params.size()>0) jpql.append(" and "); 61 jpql.append(" o.otherInfo like ?").append(params.size()+1); 62 params.add(otherInfo); 63 } 64 if(productName!=null && !"".equals(productName)) {//根据产品名称进行查询 65 if(params.size()>0) jpql.append(" and "); 66 jpql.append(" o.product.productName like ?").append(params.size()+1); 67 params.add(productName); 68 } 69 if(customerName!=null && !"".equals(customerName)) {//根据客户名称进行查询 70 if(params.size()>0) jpql.append(" and "); 71 jpql.append(" o.customer.customerName = ?").append(params.size()+1); 72 params.add(customerName); 73 } 74 pageView.setQueryResult(quotationService.getScrollData(pageView.getFirstResult(), 75 pageView.getMaxresult(),jpql.toString(),params.toArray()));//按条件进行查询 76 }else{ 77 pageView.setQueryResult(quotationService.getScrollData( 78 pageView.getFirstResult(), pageView.getMaxresult()));//查询所有记录 79 } 80 HttpServletRequest request = ServletActionContext.getRequest();//获得request对象 81 request.setAttribute("pageView", pageView);//保存到request范围 82 return this.SUCCESS; 83 } 84 public String getQuotationNO() { 85 return quotationNO; 86 } 87 public void setQuotationNO(String quotationNO) { 88 this.quotationNO = quotationNO; 89 } 90 public String getQuotationMan() { 91 return quotationMan; 92 } 93 public void setQuotationMan(String quotationMan) { 94 this.quotationMan = quotationMan; 95 } 96 public Date getQuotationtime() { 97 return quotationtime; 98 } 99 public void setQuotationtime(Date quotationtime) { 100 this.quotationtime = quotationtime; 101 } 102 public String getOtherInfo() { 103 return otherInfo; 104 } 105 public void setOtherInfo(String otherInfo) { 106 this.otherInfo = otherInfo; 107 } 108 public Product getProduct() { 109 return product; 110 } 111 public void setProduct(Product product) { 112 this.product = product; 113 } 114 public Customer getCustomer() { 115 return customer; 116 } 117 public void setCustomer(Customer customer) { 118 this.customer = customer; 119 } 120 public String getProductName() { 121 return productName; 122 } 123 public void setProductName(String productName) { 124 this.productName = productName; 125 } 126 public String getCustomerName() { 127 return customerName; 128 } 129 public void setCustomerName(String customerName) { 130 this.customerName = customerName; 131 } 132 }
12.
1 package com.sanqing.action; 2 3 import javax.annotation.Resource; 4 import javax.servlet.http.HttpServletRequest; 5 6 import org.apache.struts2.ServletActionContext; 7 import org.springframework.context.annotation.Scope; 8 import org.springframework.stereotype.Controller; 9 10 import com.sanqing.po.Customer; 11 import com.sanqing.po.Product; 12 import com.sanqing.po.Quotation; 13 import com.sanqing.service.CustomerService; 14 import com.sanqing.service.ProductService; 15 import com.sanqing.service.QuotationService; 16 @Controller("quotationManageAction") 17 @Scope("prototype") 18 public class QuotationManageAction extends BaseAction { 19 @Resource 20 private QuotationService quotationService; //报价业务逻辑组件 21 @Resource 22 private ProductService productService ; //产品业务逻辑组件 23 @Resource 24 private CustomerService customerService; //客户业务逻辑组件 25 private String quotationNO; // 报价编号 26 private String quotationMan; // 报价人 27 private String otherInfo; // 其他信息 28 private Product product ; //产品信息 29 private Customer customer; //客户信息 30 public String addUI() { //跳转到报价信息输入页面 31 HttpServletRequest request = 32 ServletActionContext.getRequest();//获得request对象 33 request.setAttribute("products", 34 productService.getScrollData().getResultlist());//保存产品信息列表 35 request.setAttribute("customers", 36 customerService.getScrollData().getResultlist());//保存客户信息列表 37 return "add"; 38 } 39 public String add() { //完成报价信息的录入 40 Quotation quotation = new Quotation();//实例化一个Quotation对象 41 quotation.setCustomer(customer);//设置客户信息 42 quotation.setOtherInfo(otherInfo);//设置其他信息 43 quotation.setProduct(product);//设置产品信息 44 quotation.setQuotationNO(quotationNO);//设置报价编号 45 quotation.setQuotationMan(quotationMan);//设置报价人 46 quotationService.save(quotation);//保存报价信息 47 return "pub_add_success";//跳转到录入成功页面 48 } 49 public String updateUI() { //跳转到报价信息修改页面 50 HttpServletRequest 51 request = ServletActionContext.getRequest();//获得request对象 52 request.setAttribute("products", 53 productService.getScrollData().getResultlist());//获得产品信息并保存 54 request.setAttribute("customers", 55 customerService.getScrollData().getResultlist());//获得客户信息并保存 56 request.setAttribute("quotation", 57 quotationService.find(quotationNO));//获得报价信息并保存 58 return "update"; 59 } 60 public String update() { 61 Quotation quotation = new Quotation();//实例化一个Quotation对象 62 quotation.setCustomer(customer);//设置客户信息 63 quotation.setOtherInfo(otherInfo);//设置其他信息 64 quotation.setProduct(product);//设置产品信息 65 quotation.setQuotationNO(quotationNO);//设置报价编号 66 quotation.setQuotationMan(quotationMan);//设置报价人 67 quotationService.update(quotation);//更新报价信息 68 return "pub_update_success";//跳转到更新成功页面 69 } 70 public String del() {//删除报价信息 71 quotationService.delete(quotationNO);//调用业务逻辑组件完成删除 72 return "pub_del_success";//跳转到删除成功页面 73 } 74 /** 75 * 查询报价 76 * @return 77 */ 78 public String query() { 79 return "query"; 80 } 81 public String getQuotationNO() { 82 return quotationNO; 83 } 84 public void setQuotationNO(String quotationNO) { 85 this.quotationNO = quotationNO; 86 } 87 public String getQuotationMan() { 88 return quotationMan; 89 } 90 public void setQuotationMan(String quotationMan) { 91 this.quotationMan = quotationMan; 92 } 93 public String getOtherInfo() { 94 return otherInfo; 95 } 96 public void setOtherInfo(String otherInfo) { 97 this.otherInfo = otherInfo; 98 } 99 public Product getProduct() { 100 return product; 101 } 102 public void setProduct(Product product) { 103 this.product = product; 104 } 105 public Customer getCustomer() { 106 return customer; 107 } 108 public void setCustomer(Customer customer) { 109 this.customer = customer; 110 } 111 112 }
13.
1 package com.sanqing.action; 2 3 import javax.annotation.Resource; 4 import javax.servlet.http.HttpServletRequest; 5 6 import org.apache.struts2.ServletActionContext; 7 import org.springframework.context.annotation.Scope; 8 import org.springframework.stereotype.Controller; 9 10 import com.sanqing.po.User; 11 import com.sanqing.service.UserService; 12 import com.sanqing.util.PageView; 13 14 @Controller("userAction") 15 @Scope("prototype") 16 public class UserAction extends BaseAction { 17 18 @Resource 19 private UserService userService; 20 /* 用户名 */ 21 private String username; 22 /* 密码 */ 23 private String password; 24 /* 级别 */ 25 private int grade; 26 @Override 27 public String execute() throws Exception { 28 PageView<User> pageView = new PageView<User>(5, getPage()); 29 if("true".equals(getQuery())) { 30 if(username!=null && !"".equals(username)) { 31 pageView.setQueryResult(userService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult(), " o.username like ?1", new Object[]{username})); 32 } 33 }else { 34 pageView.setQueryResult(userService.getScrollData(pageView.getFirstResult(), pageView.getMaxresult())); 35 } 36 HttpServletRequest request = ServletActionContext.getRequest(); 37 request.setAttribute("pageView", pageView); 38 return this.SUCCESS; 39 } 40 41 public String getUsername() { 42 return username; 43 } 44 public void setUsername(String username) { 45 this.username = username; 46 } 47 public String getPassword() { 48 return password; 49 } 50 public void setPassword(String password) { 51 this.password = password; 52 } 53 public int getGrade() { 54 return grade; 55 } 56 public void setGrade(int grade) { 57 this.grade = grade; 58 } 59 }
14.
1 package com.sanqing.action; 2 3 import javax.annotation.Resource; 4 import javax.servlet.http.HttpServletRequest; 5 6 import org.apache.struts2.ServletActionContext; 7 import org.springframework.context.annotation.Scope; 8 import org.springframework.stereotype.Controller; 9 10 import com.sanqing.po.User; 11 import com.sanqing.service.UserService; 12 13 @Controller("userManageAction") 14 @Scope("prototype") 15 public class UserManageAction extends BaseAction { 16 17 @Resource 18 private UserService userService; 19 /* 用户名 */ 20 private String username; 21 /* 密码 */ 22 private String password; 23 /* 级别 */ 24 private int grade; 25 /** 26 * 添加用户输入界面 27 * @return 28 */ 29 public String addUI() { 30 return "add"; 31 } 32 /** 33 * 添加用户 34 * @return 35 */ 36 public String add() { 37 User user = new User(); 38 user.setGrade(grade); 39 user.setPassword(password); 40 user.setUsername(username); 41 userService.save(user); 42 return "pub_add_success"; 43 } 44 /** 45 * 修改界面 46 * @return 47 */ 48 public String updateUI() { 49 User user = userService.find(username); 50 HttpServletRequest request = ServletActionContext.getRequest(); 51 request.setAttribute("user", user); 52 return "update"; 53 } 54 /** 55 * 修改界面 56 * @return 57 */ 58 public String update() { 59 User user = new User(); 60 user.setGrade(grade); 61 user.setUsername(username); 62 user.setPassword(password); 63 userService.update(user); 64 return "pub_update_success"; 65 } 66 /** 67 * 删除 68 * @return 69 */ 70 public String del() { 71 userService.delete(username); 72 return "pub_del_success"; 73 } 74 /** 75 * 查询用户 76 * @return 77 */ 78 public String query() { 79 return "query"; 80 } 81 public String getUsername() { 82 return username; 83 } 84 public void setUsername(String username) { 85 this.username = username; 86 } 87 public String getPassword() { 88 return password; 89 } 90 public void setPassword(String password) { 91 this.password = password; 92 } 93 public int getGrade() { 94 return grade; 95 } 96 public void setGrade(int grade) { 97 this.grade = grade; 98 } 99 100 }
You can do anything you set your mind to, man!