Java--Servlet如何标准创建

 

创建步骤

1、右键,new->class新建一个ServletName类继承于HttpServlet
2、快捷键Alt+Shift+S —> Override/Implement Methods,勾选

doGet(HttpServletRequest,HttpServletRequest)、doPost(HttpServletRequest,HttpServletResponse)

实例代码

package com.sale.controll;

import java.io.IOException;

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


/**
 * @author 作者:Justin
 * @version 创建时间:2017年09月18日 下午07:45:43
 * 如何创建一个标准的Servlet类
 */
public class ServletName extends HttpServlet{


	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doGet(req, resp);
	}


	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doPost(req, resp);
	}	
}

 

 

 

你可能感兴趣的:(P1:Java)