-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Simon opened SPR-12800 and commented
It is a common requirement to generate links to controllers outside of an HttpServletRequest when generating E-Mails etc. Therefore it would be nice to have a way to create links which uses a configurable baseURI for the link generation instead of the request context path like this:
private String fromStatelessMethodCall(Object invocationInfo) {
MvcUriComponentsBuilder.MethodInvocationInfo info = (MvcUriComponentsBuilder.MethodInvocationInfo) invocationInfo;
Method method = info.getControllerMethod();
String typePath = getTypeRequestMapping(method.getDeclaringClass());
String methodPath = getMethodRequestMapping(method);
String path = pathMatcher.combine(typePath, methodPath);
UriComponentsBuilder builder = UriComponentsBuilder.fromUri(baseURI).path(path);
UriComponents uriComponents = applyContributors(builder, method, info.getArgumentValues());
return uriComponents.toUriString();
}
Affects: 4.1.5
Issue Links:
- Allow customizing "base" path in MvcUriComponentsBuilder (e.g. path prefix for locale) [SPR-12617] #17218 Allow customizing "base" path in MvcUriComponentsBuilder (e.g. path prefix for locale)
Referenced from: commits febcd0c
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement