样式,动态加载

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wanggeying/article/details/52610501
示例:


jsp页面:


<link rel="stylesheet" href="${pageContext.request.contextPath}/data/icon/iconStyle.do"><!-- 加载所有模块图标样式 -->
control:


/**
* 获取所有图片样式
* @param query
* @return
* @throws Exception
*/
@RequestMapping(ICON_STYLE)
public @ResponseBody String iconStyle() throws Exception {
String getAllIconsStyle="";
Set<String> queryColumnSet = ResultColumnUtils.emptySet().add(DataIconResourceField.id,DataIconResourceField.url,DataIconResourceField.style).retSet();
List<DataIconResource> dataIconResourceList=this.dataIconResourceService.getListAll(queryColumnSet, true);
for(int i=0;i<dataIconResourceList.size();i++){
String iconStyle="."+dataIconResourceList.get(i).getStyle()+" {"+
"background-image:url("+dataIconResourceList.get(i).getUrl()+");"
+"}";
if(i>0){
getAllIconsStyle=getAllIconsStyle+iconStyle;
}else{
getAllIconsStyle=iconStyle;
}
}
return getAllIconsStyle;
}

猜你喜欢

转载自blog.csdn.net/wanggeying/article/details/52610501