📄 showgoodsclservlet.java
字号:
package com.sp.serlvet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sp.model.*;
public class ShowGoodsClServlet 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 {
response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
//得到type,判断用户是想分页,还是想显示货物的详细信息
String type=request.getParameter("type");
if(type.equals("showDetail")){
//得到要显示的货物的id
String goodsId=request.getParameter("id");
//调用GoodsBeanBO(小红)[可以给你得到货物的具体信息]
GoodsBeanBO gbb=new GoodsBeanBO();
GoodsBean gb=gbb.getGoodsBean(goodsId);
//把gb放入request
request.setAttribute("goodsInfo", gb);
//跳转
request.getRequestDispatcher("showDetail.jsp").forward(request, response);
}else if(type.equals("fenye")) {
//得到pageNow
String pageNow=request.getParameter("pageNow");
//把pageNow放入到request
request.setAttribute("abc", pageNow);
//跳回购物大厅
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @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 doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -