servlet基础(2)
<url-pattern>/mars/firstTest</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ServletTest2</servlet-name>
<servlet-class>com.mars.ServletTest2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletTest2</servlet-name>
<url-pattern>/ServletTest2</url-pattern>
</servlet-mapping>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>helloworld</servlet-name>
<servlet-class>com.mars.ServletTest</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>helloworld</servlet-name>
<url-pattern>/helloworld</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>helloworld</servlet-name>
<url-pattern>/mars/firstTest</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ServletTest2</servlet-name>
<servlet-class>com.mars.ServletTest2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletTest2</servlet-name>
<url-pattern>/ServletTest2</url-pattern>
</servlet-mapping>
</web-app>
[java]
package com.mars;
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;
public class ServletTest extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter out = resp.getWriter();
相关新闻>>
- 发表评论
-
- 最新评论 更多>>