1

这是错误日志,有人可以帮我看看可能会磨损什么吗?

In-place deployment at E:\Pavan\Java Web Apps\WebApplication2\build\web
Initializing...
deploy?DEFAULT=E:\Pavan\Java Web Apps\WebApplication2\build\web&name=WebApplication2&contextroot=/WebApplication2&force=true failed on GlassFish Server 3+ 
 Error occurred during deployment: Exception while deploying the app [WebApplication2] : Deployment descriptor file WEB-INF/web.xml in archive [web]. Element [servlet] is not a valid root element. Please see server.log for more details.
E:\Pavan\Java Web Apps\WebApplication2\nbproject\build-impl.xml:1022: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 2 seconds)

这是我的web.xml

<?xml version="1.0" encoding="UTF-8"?>
<servlet>
<servlet-name>
Example
</servlet-name>
<servlet-class>Exmple Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Example</servlet-name>
<url-pattern>/Example/*</url-pattern>
</servlet-mapping>
<web-app 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_3_0.xsd"
 version="3.0">
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
</web-app>

我的主要目标是创建一个简单的文件来接受用户名和密码,然后将其显示在另一个页面上。

4

2 回答 2

2

您的元素web.xml顺序错误。您似乎已将<servlet>元素插入顶部而不是<web-app>元素内部。

它需要看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd"
 version="3.0">
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<servlet>
<servlet-name>
Example
</servlet-name>
<servlet-class>Exmple Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Example</servlet-name>
<url-pattern>/Example/*</url-pattern>
</servlet-mapping>
</web-app>

另外,我很确定,你的 servlet 类名不是Exmple Servlet. :-) 如果您尝试像这样启动它,应用程序仍然会抛出错误。

于 2012-10-15T11:25:52.477 回答
0

<webapp>一开始就失踪了。

于 2012-10-15T11:26:56.183 回答