Avoid regex pattern matching for simple String replacement steps
Issue: SPR-17279
This commit is contained in:
@@ -38,7 +38,7 @@ import org.springframework.web.util.TagUtils;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
|
||||
/**
|
||||
* The {@code <url>} tag creates URLs. Modeled after the JSTL c:url tag with
|
||||
* The {@code <url>} tag creates URLs. Modeled after the JSTL {@code c:url} tag with
|
||||
* backwards compatibility in mind.
|
||||
*
|
||||
* <p>Enhancements to the JSTL functionality include:
|
||||
@@ -361,7 +361,8 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
|
||||
usedParams.add(param.getName());
|
||||
String value = param.getValue();
|
||||
try {
|
||||
uri = uri.replace(template, (value != null ? UriUtils.encodePath(value, encoding) : ""));
|
||||
uri = StringUtils.replace(uri, template,
|
||||
(value != null ? UriUtils.encodePath(value, encoding) : ""));
|
||||
}
|
||||
catch (UnsupportedCharsetException ex) {
|
||||
throw new JspException(ex);
|
||||
@@ -373,7 +374,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
|
||||
usedParams.add(param.getName());
|
||||
String value = param.getValue();
|
||||
try {
|
||||
uri = uri.replace(template,
|
||||
uri = StringUtils.replace(uri, template,
|
||||
(value != null ? UriUtils.encodePathSegment(param.getValue(), encoding) : ""));
|
||||
}
|
||||
catch (UnsupportedCharsetException ex) {
|
||||
|
||||
@@ -194,7 +194,7 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration
|
||||
protected URL resolveTemplate(ClassLoader classLoader, String templatePath) throws IOException {
|
||||
MarkupTemplateEngine.TemplateResource resource = MarkupTemplateEngine.TemplateResource.parse(templatePath);
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
URL url = classLoader.getResource(resource.withLocale(locale.toString().replace("-", "_")).toString());
|
||||
URL url = classLoader.getResource(resource.withLocale(StringUtils.replace(locale.toString(), "-", "_")).toString());
|
||||
if (url == null) {
|
||||
url = classLoader.getResource(resource.withLocale(locale.getLanguage()).toString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user