1.Servlet的使用方法
1
*/
public class FirstServlet extends HttpServlet{
@Override
protected void doGet(HttpServletRequest requst, HttpServletResponse response) throws ServletException, IOException {
//这个是第一个servelet
response.getWriter().write("this is my firsetServlet");
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
doGet(request, response);
}
}
2.web.xml配置文件
<!--servelt配置文件-->
<servlet>
<servlet-name>FirstServlet</servlet-name>
<servlet-class>com.zhu.servlet.FirstServlet</servlet-class>
<!--这个是自动加载的配置 整数代表优先级,整数越小说明优先级越高-->
<load-on-startup>1</load-on-startup>
</servlet>
<!--sevelt映射-->
<servlet-mapping>
<servlet-name>FirstServlet</servlet-name>
<url-pattern>/FirstServlet</url-pattern>
</servlet-mapping>
网友评论