How to stop vaadin stealing all url templates (and play well with spring mvc)

I have a vaadin application and I am trying to provide some of the REST URLs provided by spring MVC, next to my web.xml below. I only get 404 with / info - it seems like Vaadin is stealing all url patterns.

If I remove Vaadin, I can get / info and get the content at this URL. How can I make them play together?

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml
    </param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
    <description>Vaadin production mode</description>
    <param-name>productionMode</param-name>
    <param-value>false</param-value>
</context-param>

<servlet>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
    <!-- replace standard applicationServlet with the ICEpush one -->
    <!--<servlet-class>org.vaadin.artur.icepush.ICEPushServlet</servlet-class>-->
    <init-param>
        <description>Vaadin application class to start</description>
        <param-name>application</param-name>
        <param-value>myapp.vaadin.MyVaadinApp</param-value>
    </init-param>
    <init-param>
        <param-name>widgetset</param-name>
        <param-value>myapp.gwt.MyAppWidgetSet</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <url-pattern>/VAADIN/*</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>info</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>info</servlet-name>
    <url-pattern>/info</url-pattern>
</servlet-mapping>
+3
source share
3 answers

Thanks to the help of the Vaadin forum, the answer turned out to be useful / info / *, and not / info. Sorry, I couldn’t answer easily, because I initially forgot to include serv / info in the question!

+1
source

url Vaadin /*, wild-card , . , URL- , /*.

+5

, , : https://vaadin.com/forum/#!/thread/344236/376324

, -:

@WebServlet(urlPatterns = {"", "/VAADIN/*", "/UIDL"}, asyncSupported = true)

( jsp) . vaadin 4.8.5.

( "/UIDL/" http://dev.vaadin.com/ticket/7386 "/UIDL" - " URL... . 12.1 12.2 " )

- :( http://.../r/...


( ), :

, , url, "/info/a", "/info", "/*", ( * = = "info/a" ). "/" "/info/", , , .

Vaadin , URL REST . - /ui REST. , , , / . , , - , . , , /* Vaadin, /login.jsp JSP, .

Java EE 6, Vaadin , . web.xml:

@WebServlet(urlPatterns = {"/ui/*", "/VAADIN/*"})
public static class MyServlet extends AbstractApplicationServlet {
    // ...
}

web.xml :

<servlet>
    <!-- technically, a JSP is a servlet -->
    <servlet-name>index</servlet-name>
    <jsp-file>index.jsp</jsp-file>
</servlet>
<servlet>
    <!-- this is the Jersey REST servlet -->
    <servlet-name>ServletAdaptor</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- We'll map / to the welcome page and /* to our resources. -->
<servlet-mapping>
    <servlet-name>index</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>ServletAdaptor</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

So, I have established that / * will match any REST resource that I add if it is not / ui / *. When a user first visits the site, he / she is sent to index.jsp, which is simple:

This is probably a lot more than you want to know, but maybe it will help someone. If the user interface is a secondary part of the web application, I like it if it sits at a specific URL rather than using / * for it.

+2
source

All Articles