?? controller.java
字號:
package bean;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Controller extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GB2312";
//Initialize global variables
public void init() throws ServletException {
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
}
//Process the HTTP Post request
public void doPost(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {
String command=req.getParameter("command");
HttpSession session=req.getSession();
FurnitureCart cart=(FurnitureCart)session.getAttribute("cart");
if(command.equals("add"))
{
String id=req.getParameter("id");
if(id!=null)
{
String b_name=req.getParameter("name");
Float b_price=new Float(req.getParameter("b_price"));
int quanlity=new Integer(req.getParameter("quanlity"));
cart.addItem(id,b_name,b_price.floatValue(),quanlity);
}
}
res.sendRedirect("/bookshop/main.jsp");
}
//Clean up resources
public void destroy() {
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -