<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=rkroll" rel="nofollow">Rich Kroll</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-6486?redirect=false" rel="nofollow">SPR-6486</a></strong> and commented</p>
<p dir="auto">I have a URI template in the form of "/hotels/{hotel}/bookings/{booking}", and can access the path variables in the controller via <code class="notranslate">@PathVariable</code>, but when building links in the view I need a reference to the different path variables.</p>
<p dir="auto">As an example, let's say the user requests "/hotels/Hotelier/bookings/booking-123", and as is a common use case in the view, there is a need to link back to the bookings listing "/hotels/Hotelier/bookings/". The only way currently to access the URI template variables is to manually inject them each time into the view.  I suggest that a tag be created that is capable of building a link from the same URI template style that is used in the <code class="notranslate">@RequestMapping</code>, something like &lt;spring:a link="/hotels/{hotel}"&gt;go&lt;/spring:a&gt;.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0 M1, 3.0 M2, 3.0 M3, 3.0 M4, 3.0 RC1, 3.0 RC2, 3.0 RC3</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398107398" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12200" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12200/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12200">#12200</a> Automatically expose <code class="notranslate">@PathVariables</code> in the Model (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">7 votes, 6 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=karldmoore" rel="nofollow">Karl Moore</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-2770?redirect=false" rel="nofollow">SPR-2770</a></strong> and commented</p>
<p dir="auto">The example code in the Lookup method injection section (3.3.8.1) doesn't compile.  There are duplicate local variables, the abstract method returns the wrong type, its got the wrong method name and the class isn't abstract.  I think the code should look something like below.</p>
<p dir="auto">public abstract class CommandManager<br>
{<br>
public Object process ( Object commandState )<br>
{<br>
// grab a new instance of the appropriate Command interface<br>
Command command = createCommand ();<br>
// set the state on the (hopefully brand new) Command instance<br>
command.setState ( commandState );<br>
return command.execute ();<br>
}</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// mmm, but where is the implementation of this method?
protected abstract Command createCommand ();"><pre class="notranslate"><code class="notranslate">// mmm, but where is the implementation of this method?
protected abstract Command createCommand ();
</code></pre></div>
<p dir="auto">}</p>
<p dir="auto">public interface Command<br>
{<br>
public void setState ( Object commandState );<br>
public boolean execute ();<br>
}</p>
<p dir="auto">public class AsyncCommand implements Command<br>
{<br>
private Object commandState;</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public AsyncCommand ()
{
	System.out.println ( &quot;Created AsyncCommand&quot; );
}

public void setState ( Object commandState )
{
	this.commandState = commandState;
}

public boolean execute ()
{
	System.out.println ( commandState );
	return true;
}"><pre class="notranslate"><code class="notranslate">public AsyncCommand ()
{
	System.out.println ( "Created AsyncCommand" );
}

public void setState ( Object commandState )
{
	this.commandState = commandState;
}

public boolean execute ()
{
	System.out.println ( commandState );
	return true;
}
</code></pre></div>
<p dir="auto">}</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0 final</p>