GoodTypeAction.java
资源名称:Jason.rar [点击查看]
上传用户:wok5188
上传日期:2018-02-20
资源大小:1835k
文件大小:4k
源码类别:
MySQL数据库
开发平台:
Java
- /*
- * Generated by MyEclipse Struts
- * Template path: templates/java/JavaClass.vtl
- */
- package com.center.control;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.HashMap;
- import java.util.Map;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.actions.LookupDispatchAction;
- import com.center.commons.DataConnect;
- import com.center.util.DealString;
- /**
- * MyEclipse Struts
- * Creation date: 05-19-2007
- *
- * XDoclet definition:
- * @struts.action path="/goodType" name="goodTypeForm" input="/show/admin/goodType.jsp" parameter="method" scope="request" validate="true"
- * @struts.action-forward name="adderr" path="/adderr.jsp"
- * @struts.action-forward name="addok" path="/addok.jsp"
- */
- public class GoodTypeAction extends LookupDispatchAction {
- /*
- * Generated Methods
- */
- /**
- * Method execute
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- */
- Connection conn;
- public ActionForward showtype(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) throws IOException{
- GoodTypeForm goodTypeForm = (GoodTypeForm) form;// TODO Auto-generated method stub
- System.out.println("ddd");
- conn = new DataConnect().getConn();
- request.getParameter("typename");
- request.getParameter("typetime");
- request.getParameter("typeid");
- GoodTypemodel goodtypemodel = null;
- ResultSet rs = (ResultSet)new GoodTypemodel(conn).showtype();
- response.setContentType("text/html;charset=gbk");
- PrintWriter out = response.getWriter();
- HttpSession session = request.getSession();
- //out.println("<form >关键字:<input type='text' name='typename'><br>商品类型:<select name='typename'>");
- session.setAttribute("typename", rs);
- // out.println("<option value="+rs.getString(1)+">"+rs.getString(1)+"</option>");
- // out.println("</select></form>");
- System.out.println(session.getAttribute("typename"));
- if(session != null){
- response.sendRedirect("left.jsp");
- }
- return null;
- }
- public ActionForward addtype(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) throws IOException{
- GoodTypeForm goodTypeForm = (GoodTypeForm) form;// TODO Auto-generated method stub
- System.out.println("ddd");
- String typename = request.getParameter("typename");
- String typetime = DealString.getDateTime();
- if(!typename.equals("")){
- typename = DealString.toGBK(typename);
- }
- conn = new DataConnect().getConn();
- request.getParameter("typename");
- GoodTypemodel goodtypemodel = null;
- int i = 0;
- try {
- i = new GoodTypemodel(conn).addtype(typename,typetime);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if(i == 1){
- response.sendRedirect(request.getContextPath()+"/show/admin/addtypeok.jsp");
- }else{
- response.sendRedirect(request.getContextPath()+"/show/admin/addtypeerr.jsp");
- }
- return null;
- }
- private Object goodtypemodel(Connection conn2) {
- // TODO Auto-generated method stub
- return null;
- }
- @Override
- protected Map getKeyMethodMap() {
- // TODO Auto-generated method stub
- HashMap map = new HashMap();
- map.put("show", "showtype");
- map.put("button.addtype", "addtype");
- return map;
- }
- }