SPR-7543 Add @PathVariables to the model

This commit is contained in:
Rossen Stoyanchev
2011-04-21 15:18:45 +00:00
parent a4716c2a94
commit ed9d9a402b
4 changed files with 46 additions and 11 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.ValueConstants;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.method.annotation.support.AbstractNamedValueMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
import org.springframework.web.servlet.HandlerMapping;
/**
@@ -73,6 +74,17 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod
throw new IllegalStateException("Could not find the URL template variable [" + name + "]");
}
@Override
protected void handleResolvedValue(Object arg,
String name,
MethodParameter parameter,
ModelAndViewContainer mavContainer,
NativeWebRequest webRequest) {
if (mavContainer != null) {
mavContainer.addAttribute(name, arg);
}
}
private static class PathVariableNamedValueInfo extends NamedValueInfo {
private PathVariableNamedValueInfo(PathVariable annotation) {