⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcaddtypeservlet.java

📁 电子商城
💻 JAVA
字号:
package com.lmh.servlet.admin;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lmh.dao.impl.OracleMcTypeDAO;
import com.lmh.dao.vo.McTypeBean;
import com.lmh.pub.EncodingTool;

public class McAddTypeServlet extends HttpServlet {

	/**
	 * The doGet method of the servlet. <br>
	 * 
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request
	 *            the request send by the client to the server
	 * @param response
	 *            the response send by the server to the client
	 * @throws ServletException
	 *             if an error occurred
	 * @throws IOException
	 *             if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int maxid = -1;
		String title = "";
		String url = "";
		String content = "";

		String typeName = request.getParameter("typeName");
		try {
			maxid = Integer.parseInt(request.getParameter("maxid"));
		} catch (Exception e) {
		}
		OracleMcTypeDAO mcTypeDao = new OracleMcTypeDAO();
		List mcTypeList = mcTypeDao.searchMcType(-1, null);
		request.setAttribute("mcTypeList", mcTypeList);
		McTypeBean mcTypeBean = new McTypeBean();
		if (typeName != null && !typeName.equals("")) {
			if (maxid != -1 && typeName != null) {
				mcTypeBean.setNpid(maxid);
				mcTypeBean.setSname(typeName);
				mcTypeDao.insertMcType(mcTypeBean);
				title = "添加成功";
				content = "类别名[" + typeName + "]已经成功被添加!";
				url = "/lmhshop/admin/mcManager/mcType.jsp";
			} else {
				title = "添加失败";
				content = "类别名[" + typeName + "]添加失败!";
				url = "/lmhshop/admin/mcManager/mcType.jsp";
			}
			content = content + "本页面将在5秒后自动跳转";
			title = EncodingTool.encoder(title);
			content = EncodingTool.encoder(content);
			url = EncodingTool.encoder(url);

			response.sendRedirect("/lmhshop/publicInfo.jsp?title=" + title
					+ "&url=" + url + "&content=" + content);
		} else {
			if (request.getParameter("addTypeTag") != null) {
				title = "添加失败";
				content = "类别名不能为空,请重新填写或返回编辑页!";
				url = "/lmhshop/admin/mcManager/mcType.jsp";
				
				content = content + "本页面将在5秒后自动跳转";
				title = EncodingTool.encoder(title);
				content = EncodingTool.encoder(content);
				url = EncodingTool.encoder(url);

				response.sendRedirect("/lmhshop/publicInfo.jsp?title=" + title
						+ "&url=" + url + "&content=" + content);
			} else {
				RequestDispatcher rd = request
						.getRequestDispatcher("/admin/mcManager/mcType.jsp");
				rd.forward(request, response);
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -