首页 > 编程语言 >第3章 程序填空题

第3章 程序填空题

时间:2022-10-16 21:15:08浏览次数:34  
标签:HttpServletRequest 程序 填空题 request HttpServletResponse doPost public response

1.请补充下边的代码,完成Servlet的基本架构。本实例主要功能由doPost完成。

public class ServletName extends  HttpServlet {  
  
	public void  doPost (HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { }  
      
              
public void  doGet  (HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {   doPost(request,response);  }  
  
}  

2.在web.xml中添加/修改代码,完成servlet的配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <servlet>
        <!--给servlet起一个名字,名字为“Hello”-->
        <servlet-name>Hello</servlet-name>
        <!--指明编译后的servlet的.class文件在classes文件夹中的完整路径,路径为(包名+类名),本例中为edu.qlu.HelloServlet-->
        <servlet-class>edu.qlu.HelloServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <!--给servlet起一个名字,名字可以任意,由于是mapping(映射),所以名字应该和上面名字一致-->
        <servlet-name>Hello</servlet-name>
        <!--给servlet起一个名字,名字可以任意,由于是mapping(映射),所以名字应该和上面名字一致-->
        <url-pattern>/hs</url-pattern>
    </servlet-mapping>
</web-app>

标签:HttpServletRequest,程序,填空题,request,HttpServletResponse,doPost,public,response
From: https://www.cnblogs.com/purearc/p/16797134.html

相关文章