Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You might want to look at the <a href="http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html#mvc-coc" rel="noreferrer">convention over configuration</a> support of Spring 3, specifically <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/servlet/mvc/support/ControllerClassNameHandlerMapping.html" rel="noreferrer">ControllerClassNameHandlerMapping</a>. Effectively you don't define the location of the URL in a <code>@RequestMapping</code> but it's defined by the package location of the handler.</p> <p>If you want to have the mapped URLs reflect the package name of controller then you should set the <code>basePackage</code> property of the <code>ControllerClassNameHandlerMapping</code>. The <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/servlet/mvc/support/ControllerClassNameHandlerMapping.html#setBasePackage%28java.lang.String%29" rel="noreferrer">documentation</a> says</p> <blockquote> <p>Set the base package to be used for generating path mappings, including all subpackages underneath this packages as path elements. Default is null, using the short class name for the generated path, with the controller's package not represented in the path. Specify a base package like "com.mycompany.myapp" to include subpackages within that base package as path elements, e.g. generating the path "/mymodule/buyform" for the class name "com.mycompany.myapp.mymodule.BuyForm". Subpackage hierarchies are represented as individual path elements, e.g. "/mymodule/mysubmodule/buyform" for the class name "com.mycompany.myapp.mymodule.mysubmodule.BuyForm".</p> </blockquote> <p>So, an example beans definition might be</p> <pre><code>&lt;bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"&gt; &lt;property name="basePackage" value="com.company.project"/&gt; &lt;/bean&gt; &lt;context:component-scan base-package="com.company.project.ws"/&gt; </code></pre> <p>And your controllers might look like</p> <pre><code>package com.company.project.ws; @Controller public class Service1 { // your controller methods } </code></pre>
 

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