样式,动态加载

来源:互联网 发布:淘宝怎么刷流量安全 编辑:程序博客网 时间:2024/06/01 09:53

示例:

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;
}

0 0
原创粉丝点击