首相说明一下,我是新手,对于帮助我的人,我表示感谢!问题:这个servlet是跟着视频做的,步骤我感觉都是对的,但是就是运行不出来,已经困扰了我一段时间,学习就卡在了这里相关java代码和web.xml代码:package ww;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class HelloWordServlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("doGet"); response.getWriter().write("<a href='www.baidu.com'>go</a>");}}<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" id="WebApp_ID"xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><!-- 配置Servlet --><servlet> <servlet-name>HW</servlet-name> <servlet-class>HelloWordServlet</servlet-class></servlet><!-- 配置Servlet映射路径 --><servlet-mapping> <servlet-name>HW</servlet-name> <url-pattern>/abc</url-pattern></servlet-mapping></web-app>
5 回答

慕丝7291255
TA贡献1859条经验 获得超6个赞
1、在web.xml中配置servlet时需要使用类全名;
2、访问servlet:http:hostname:port/projectName/urlMapping
添加回答
举报
0/150
提交
取消