【问题标题】:Web.xml error while adding servlet mapping添加 servlet 映射时出现 Web.xml 错误
【发布时间】:2015-02-21 17:08:11
【问题描述】:

我有

<?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。

【问题讨论】:

  • 服务器是否抛出任何错误?
  • 将属性 'source' 设置为 'org.eclipse.jst.jee.server:Project1' 没有找到匹配的属性。
  • 我很确定这只是一个警告。
  • 您的服务器没有提出这些更改,或者您的表单提交不起作用?

标签: java xml jsp servlets


【解决方案1】:

您必须将 servlet (.class) 的编译副本保存在 WEB-INF/classes 文件夹中...... 并检查 CLASSPATH 是否为 servlet 和 jsp 设置 看起来像这样 \tomcat\lib\servlet-api.jar 和 tomcat\lib\jsp-api.jar

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-01
    • 2013-01-20
    • 1970-01-01
    • 2018-04-15
    • 2012-07-23
    • 2016-07-05
    • 2014-09-04
    • 2012-04-17
    相关资源
    最近更新 更多