Note that there are some explanatory texts on larger screens.

plurals
  1. POPath specs and multiple servlets
    primarykey
    data
    text
    <p>I'd like to have two servlets (I'm using Jetty) serve URLs like this:</p> <pre><code>host/aaa/submit host/bbb/submit </code></pre> <p>I've tried setting the servlets' pathspecs to <code>aaa</code> and <code>bbb</code> respectively, but then I get an exception along the lines of </p> <pre><code>two controller methods annotated with @RequestMapping(value = {"/submit"}) </code></pre> <p>(even though the two methods in question are defined in two separate controller classes that are used by two different servlets).<br> if instead I set both servlets' pathspecs to <code>/</code> and change the <code>@RequestMappings</code> to <code>aaa/submit</code> and <code>bbb/submit</code>, I'm getting 404s. (This, I suppose, is less surprising - not sure how it should work with effectively two 'default' servlets)</p> <p>How should I map those URLs? (preemptively - they <strong>do</strong> need to be separate servlets - <code>aaa</code> part should work with or without DB, <code>bbb</code> part should fail without DB)</p> <p>Just in case, here's the Jetty context:</p> <pre><code> &lt;property name="servletHandler"&gt; &lt;bean class="org.mortbay.jetty.servlet.ServletHandler"&gt; &lt;property name="servlets"&gt; &lt;list&gt; &lt;bean name="aaaServlet" class="org.mortbay.jetty.servlet.ServletHolder"&gt; &lt;property name="name" value="aaa" /&gt; &lt;property name="servlet"&gt; &lt;bean class="org.springframework.web.servlet.DispatcherServlet" /&gt; &lt;/property&gt; &lt;property name="initParameters"&gt; &lt;map&gt; &lt;entry key="contextConfigLocation" value="classpath:aaa-context.xml" /&gt; &lt;/map&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean name="bbbServlet" class="org.mortbay.jetty.servlet.ServletHolder"&gt; &lt;property name="name" value="bbb" /&gt; &lt;property name="servlet"&gt; &lt;bean class="org.springframework.web.servlet.DispatcherServlet" /&gt; &lt;/property&gt; &lt;property name="initParameters"&gt; &lt;map&gt; &lt;entry key="contextConfigLocation" value="classpath:bbb-context.xml" /&gt; &lt;/map&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="servletMappings"&gt; &lt;list&gt; &lt;bean class="org.mortbay.jetty.servlet.ServletMapping"&gt; &lt;property name="servletName" value="aaa" /&gt; &lt;property name="pathSpec" value="/" /&gt; &lt;/bean&gt; &lt;bean class="org.mortbay.jetty.servlet.ServletMapping"&gt; &lt;property name="servletName" value="bbb" /&gt; &lt;property name="pathSpec" value="/" /&gt; &lt;/bean&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/property&gt; </code></pre> <p>And the two controllers that look like this:</p> <pre><code>@Controller public class AaaController { @RequestMapping(value = {"/aaa/submit"}, method = (RequestMethod.POST)) public void handleAaaSubmitPostRequest(final HttpServletRequest request, final HttpServletResponse response, @RequestBody String body) throws IOException { } </code></pre> <p>And</p> <pre><code>@Controller public class BbbController { @RequestMapping(value = {"/bbb/submit"}, method = (RequestMethod.POST)) public void handleBbbSubmitPostRequest(final HttpServletRequest request, final HttpServletResponse response, @RequestBody String body) throws IOException { } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload