com.github.ayongw.thymeleaf.dynamicurl.service.PropertyDynamicResourceLocationService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of thymeleaf-dynamic-url-dialect Show documentation
Show all versions of thymeleaf-dynamic-url-dialect Show documentation
dynamic replace resources url for thymeleaf
package com.github.ayongw.thymeleaf.dynamicurl.service;
import org.apache.commons.lang3.StringUtils;
import java.util.Map;
/**
* 根据配置的属性列表进行替换,一个默认的实现
*
* @author jiangguangtao
*/
public class PropertyDynamicResourceLocationService implements DynamicResourceLocationService {
private Map resourceMap;
public PropertyDynamicResourceLocationService(Map resourceMap) {
this.resourceMap = resourceMap;
}
@Override
public String findRemoteUrl(String localUrl) {
localUrl = StringUtils.trim(localUrl);
if (StringUtils.isBlank(localUrl)) {
return null;
}
if (null == resourceMap || resourceMap.size() == 0) {
return localUrl;
}
if (!resourceMap.containsKey(localUrl)) {
return localUrl;
}
return resourceMap.get(localUrl);
}
}