<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=vickeryj" rel="nofollow">Joshua Vickery</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-263?redirect=false" rel="nofollow">SPR-263</a></strong> and commented</p>
<p dir="auto">I am having trouble creating a bean of type java.io.File with a single constructor-arg.  The problem is that the bean that is instantiated seems to "double" its argument value.</p>
<p dir="auto">Application Context:</p>
<hr>
<p dir="auto">&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"<br>
"<a href="http://www.springframework.org/dtd/spring-beans.dtd%22%3E" rel="nofollow">http://www.springframework.org/dtd/spring-beans.dtd"&gt;</a><br>
&lt;beans&gt;<br>
&lt;bean id="dir" class="java.io.File"&gt;<br>
&lt;constructor-arg&gt;&lt;value&gt;test&lt;/value&gt;&lt;/constructor-arg&gt;<br>
&lt;/bean&gt;<br>
&lt;/beans&gt;</p>
<p dir="auto">Test code:</p>
<hr>
<p dir="auto">import java.io.File;<br>
import org.springframework.context.ApplicationContext;<br>
import org.springframework.context.support.FileSystemXmlApplicationContext;</p>
<p dir="auto">public class Test {<br>
public static void main(String[] args) throws Exception {<br>
File f1 = new File("test");<br>
System.out.println(f1.getAbsolutePath());<br>
ApplicationContext ac = new FileSystemXmlApplicationContext("applicationContext.xml");<br>
File f2 = (File)ac.getBean("dir");<br>
System.out.println(f2.getAbsolutePath());</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="}"><pre class="notranslate"><code class="notranslate">}
</code></pre></div>
<p dir="auto">}</p>
<p dir="auto">Abbreviated Output from code:</p>
<hr>
<p dir="auto">run:<br>
[java] /home/vickeryj/temp/springTest/test</p>
<p dir="auto">...</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[java] /home/vickeryj/temp/springTest/test/test"><pre class="notranslate"><code class="notranslate">[java] /home/vickeryj/temp/springTest/test/test
</code></pre></div>
<p dir="auto">In short it seems to me that both println statements should be the same, however the bean retrieved from the application context has a path of "test/test" rather than the value of "test" which I passed in.</p>
<p dir="auto">Can anyone recreate this?</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 1.0.2</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=kdonald" rel="nofollow">Keith Donald</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-6413?redirect=false" rel="nofollow">SPR-6413</a></strong> and commented</p>
<p dir="auto">Spring Roo has the requirement to map a web requests to static views.  Rather than configure a "default handler" that attempts to map any request not handled by a Controller to a view, they're now defining a ParameterizableViewController bean for each static view [which is a safer and more explicit].  This change results in some extra low-level bean configuration that could be simplified.</p>
<p dir="auto">Currently, the following must be added to mvc-config.xml:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;!-- Required to enable invocation of org.springframework.web.servlet.Controllers --&gt;
&lt;bean class=&quot;org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter&quot; /&gt;
&lt;!-- Required for bean name-based request mapping --&gt;
&lt;bean class=&quot;org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping&quot; p:order =&quot;1&quot;&gt;
    &lt;!-- Register any interceptors, typically duplicating interceptor set with other handler mappings --&gt;
    &lt;property name=&quot;interceptors&quot;&gt; ... &lt;/property&gt;
&lt;/bean&gt;
&lt;!-- Required for each static view controller --&gt;
&lt;bean name=&quot;/index&quot; class=&quot;org.springframework.web.servlet.mvc.ParameterizableViewController&quot; p:viewName=&quot;index&quot; /&gt;"><pre class="notranslate"><code class="notranslate">&lt;!-- Required to enable invocation of org.springframework.web.servlet.Controllers --&gt;
&lt;bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" /&gt;
&lt;!-- Required for bean name-based request mapping --&gt;
&lt;bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" p:order ="1"&gt;
    &lt;!-- Register any interceptors, typically duplicating interceptor set with other handler mappings --&gt;
    &lt;property name="interceptors"&gt; ... &lt;/property&gt;
&lt;/bean&gt;
&lt;!-- Required for each static view controller --&gt;
&lt;bean name="/index" class="org.springframework.web.servlet.mvc.ParameterizableViewController" p:viewName="index" /&gt;
</code></pre></div>
<p dir="auto">Proposal:</p>
<ul dir="auto">
<li>We can simplify the above config by encapsulating the registration of the SimpleControllerHandlerAdapter and BeanNameUrlHandlerMapping beans in the mvc:annotation-driven element.</li>
<li>We can simplify the registration of ParameterizableViewControllers by introducing a custom mvc namespace tag such as:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;mvc:view-controller path=&quot;/index&quot; /&gt; &lt;!-- defaults to view name &quot;index&quot; via RequestToViewNameTranslator --&gt;

&lt;mvc:view-controller path=&quot;/foo&quot; view-name=&quot;aCustomViewName&quot; /&gt;"><pre class="notranslate"><code class="notranslate">&lt;mvc:view-controller path="/index" /&gt; &lt;!-- defaults to view name "index" via RequestToViewNameTranslator --&gt;

&lt;mvc:view-controller path="/foo" view-name="aCustomViewName" /&gt;
</code></pre></div>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 RC2</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/browse/ROO-385" rel="nofollow">ROO-385</a> Use new Spring MVC namespace (<em><strong>"is depended on by"</strong></em>)</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/de1d54872565a8e62e90a4993b20251c372c0fe7/hovercard" href="https://github.com/spring-projects/spring-framework/commit/de1d54872565a8e62e90a4993b20251c372c0fe7"><tt>de1d548</tt></a></p>