我有
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>DBTest</display-name>
<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>
<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>com.package1.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/Test</url-pattern>
</servlet-mapping>
</web-app>
servlet Test.java
在
src/com.package1/Test.java
另外
WebContent/Login.jsp
已
<form method="POST" action="../Test">
</form>
当我在web.xml中添加servlet映射并在服务器上运行时,它无法连接到localhost。
答案 0 :(得分:0)
你必须在WEB-INF / classes文件夹中保存servlet(.class)的编译副本.... 并且还检查是否为servlet和jsp设置了CLASSPATH 它看起来像\ tomcat \ lib \ servlet-api.jar和tomcat \ lib \ jsp-api.jar