首相說明一下,我是新手,對于幫助我的人,我表示感謝!問題:這個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
提交
取消