1

The situation is that I work on a web project where I want to add some filter and servlet to the web.xml file. For example:

<servlet>
    <servlet-name>spring-mvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>

Here I must enter manually the servlet-class element. And the same way for the filter-class element. I think it's not very convenient.
How can I get an auto-complete feature here?

4

3 回答 3

1

Eclipse does not have a content-aware editor for web.xml, just the XML editor whose content assist is driven by the schema. This means no content assist for Java type values.

There is an effort underway to create a form editor for web.xml with all the appropriate content assist, validation, etc., but the work is not at the point where it can be used.

http://projects.eclipse.org/projects/webtools.java-ee-config

You may be able to find commercial plugins with a web.xml editor if you search for "web.xml editor for Eclipse".

于 2013-08-09T19:39:21.697 回答
0

Maybe you should try to use Spring Tools?

于 2013-08-09T19:17:50.600 回答
0

Change your xml doctype to refer to the XML schema:

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
</web-app>

Eclipse should download the schema file from http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd and use that to offer autocompletion.

For more information see this guide here.

于 2015-03-04T08:52:03.423 回答