2011-03-01 69 views
0

http://127.0.0.1:8080/testserver訪問servlet類名或servlet名

TESTSERVER它應該是這個servlet的類名的servlet名稱?

<?xml version="1.0" encoding="UTF-8"?> 
<web-app id="WebApp_ID" 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"> 
<display-name>helloTest</display-name> 
<servlet> 
    <description> 
    </description> 
    <display-name>foo</display-name> 
    <servlet-name>foo</servlet-name> 
    <servlet-class> 
    foo</servlet-class> 
</servlet> 
<servlet-mapping> 
    <servlet-name>foo</servlet-name> 
    <url-pattern>/foo9</url-pattern> 
</servlet-mapping> 
<welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
</welcome-file-list> 

行,所以我說

http://127.0.0.1:8080/helloTest/foo9 

它的工作原理,但是當我說\

http://127.0.0.1:8080/helloTest/foo 

它不工作,這是爲什麼?

回答

1

testserver應匹配<servlet-mapping>中的<url-pattern>
(或參數@WebServlet註釋)