出于练习目的,我正在使用 GWT 制作一个应用程序,其中包含一个登录表单。运行时出现错误
Loading modules com.logvin.LoginForm
[ERROR] Element 'servlet' beginning on line 19 is missing required attribute 'path'
[ERROR] Failure while parsing XML
我正在使用 GWT-RPC 并检查给定的用户名和密码是否正确。我在 xml 文件中做了一些更改:
entry-point class='com.logvin.client.LoginForm'/>
<servlet> path="/LoginForm" class="com.logvin.gwt.server.GreetingServiceImpl"/>
<servlet>
<servlet-name>GreetingServiceImpl</servlet-name>
<servlet-class>com.logvin.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GreetingServiceImpl</servlet-name>
<url-pattern>/LoginForm</url-pattern>
</servlet-mapping>
为什么我再次收到此错误?
最佳答案
您混淆了两种 XML 方言。
所有这些<servlet>
元素应该进入你的 WEB-INF/web.xml
文件,它告诉 servlet 容器(您将在其中部署应用程序的服务器)如何为您的 servlet 提供服务。
*.gwt.xml
文件(GWT 模块)是关于告诉 GWT 编译器(请参阅:编译时,而不是运行时)如何编译代码:加载应用程序时从哪里开始( entry-point
),哪些类是客户端的(将是编译为 JavaScript,其他(仅限服务器端)必须排除),要导入哪些 GWT 模块( inherits
)等。
关于java - Servlet 路径错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12779837/