cms-帖子静态化
实现帖子静态化和实现友情链接静态化一致,
1.首先建立帖子类别的实体类:
package com.open1111.entity;
/**
* 帖子类别实体
* @author user
*
*/
public class ArcType {
private Integer id; // 编号
private String typeName; // 类别名称
private Integer sortNo; // 排列序号
private String keywords; // 关键字 页面seo用到
private String description; // 类别描述 页面seo用到
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public Integer getSortNo() {
return sortNo;
}
public void setSortNo(Integer sortNo) {
this.sortNo = sortNo;
}
public String getKeywords() {
return keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
2.然后编写帖子对应的mapper
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.open1111.dao.ArcTypeDao">
<resultMap type="ArcType" id="ArcTypeResult">
<result property="id" column="id"/>
<result property="typeName" column="typeName"/>
<result property="sortNo" column="sortNo"/>
<result property="keywords" column="keywords"/>
<result property="description" column="description"/>
</resultMap>
<select id="list" parameterType="Map" resultMap="ArcTypeResult">
select * from t_arcType
order by sortNo asc
</select>
</mapper>
3.编写mapper对应的dao
package com.open1111.dao;
import java.util.List;
import java.util.Map;
import com.open1111.entity.ArcType;
/**
* 帖子类别Dao接口
* @author user
*
*/
public interface ArcTypeDao {
/**
* 根据条件分页查询帖子类别集合
* @param map
* @return
*/
public List<ArcType> list(Map<String,Object> map);
}
4.编写帖子类别的service
package com.open1111.service;
import java.util.List;
import java.util.Map;
import com.open1111.entity.ArcType;
/**
* 帖子类别Service接口
* @author user
*
*/
public interface ArcTypeService {
/**
* 根据条件分页查询帖子类别集合
* @param map
* @return
*/
public List<ArcType> list(Map<String,Object> map);
}
5.编写daoImpl
package com.open1111.service.impl;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.open1111.dao.ArcTypeDao;
import com.open1111.entity.ArcType;
import com.open1111.service.ArcTypeService;
/**
* 帖子类别Service实现类
* @author user
*
*/
@Service("arcTypeService")
public class ArcTypeServiceImpl implements ArcTypeService{
@Resource
private ArcTypeDao arcTypeDao;
public List<ArcType> list(Map<String, Object> map) {
return arcTypeDao.list(map);
}
}
6.把查询的数据放入application中:
package com.open1111.service.impl;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import com.open1111.entity.ArcType;
import com.open1111.entity.Link;
import com.open1111.service.ArcTypeService;
import com.open1111.service.LinkService;
/**
* 初始化组件
* @author user
*
*/
@Component("initComponet")
public class InitComponet implements ApplicationContextAware,ServletContextListener{
private static ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
// TODO Auto-generated method stub
this.applicationContext=applicationContext;
System.out.println(this);
}
/**
* 刷新application缓存方法
* @param application
*/
public void refreshSystem(ServletContext application){
LinkService linkService=(LinkService) applicationContext.getBean("linkService");
List<Link> linkList=linkService.list(null);
application.setAttribute("linkList", linkList);
ArcTypeService arcTypeService=(ArcTypeService) applicationContext.getBean("arcTypeService");
List<ArcType> arcTypeList=arcTypeService.list(null);
application.setAttribute("arcTypeList", arcTypeList);
}
public void contextInitialized(ServletContextEvent sce) {
// TODO Auto-generated method stub
ServletContext application=sce.getServletContext();
refreshSystem(application);
}
public void contextDestroyed(ServletContextEvent sce) {
// TODO Auto-generated method stub
}
}
7.在页面把类别显示出来
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div class="menu">
<div class="w960 m960">
<ul>
<li class="first"><a href="/index.jsp" >首页</a></li>
<c:forEach var="arcType" items="${arcTypeList }">
<li><a href="${pageContext.request.contextPath}/arcType/${arcType.id }.html">${arcType.typeName }</a></li>
</c:forEach>
</ul>
</div>
</div>
cms-帖子静态化的更多相关文章
- 阶段5 3.微服务项目【学成在线】_day04 页面静态化_23-页面预览-页面预览开发
1.用户进入cms前端,点击“页面预览”在浏览器请求cms页面预览链接. 2.cms根据页面id查询DataUrl并远程请求DataUrl获取数据模型. 3.cms根据页面id查询页面模板内容 4.c ...
- Java开源内容管理CMS系统J4CMS支持静态化直接ftp上传到你的空间了
页面可直接编辑的cms系统j4cms能够直接支持使用ftp 输出 html到你的空间了 真正的静态化 这是静态化后的站点 http://www.j4cms.com/ 源代码上传至csdn了,能够下载源 ...
- 帝国cms文章内容tags关键词设置调用方法以及tags静态化
说实话帝国cms用起来真的不好找一些功能,就比如说帝国cms的tag标签调用.需要注意的是帝国CMS文章的关键词和tags标签并非一码事,关键词标签是设置文章的关键词的,是用来给搜索引擎说明本篇文章的 ...
- CMS系统关键技术点总结(UrlRewrite、批量静态化、发送邮件)
1.UrlRewrite protected void Application_BeginRequest(object sender, EventArgs e) { //将请求的ShowArticle ...
- 利用PHP的ob函数实现生成静态化页面
之前用过一些开源的CMS管理系统,当时就很好奇后台中的生成HTML静态文件是怎么实现的.今天和同事讨论了下,没想到同事之前做过这类的生成静态页面的功能,果断向他请教了下. 经他讲解后,才知道其实生成静 ...
- 页面静态化技术Freemarker技术的介绍及使用实例.
一.FreeMarker简介 1.动态网页和静态网页差异 在进入主题之前我先介绍一下什么是动态网页,动态网页是指跟静态网页相对应的一种网页编程技术.静态网页,随着HTML代码的生成,页面的内容和显示效 ...
- JSP页面静态化
Ps:好久没写博客了,不是我太懒,是因为苦逼的我出差去上海了,天天加班 刚回成都.... 今天说说jsp页面静态化,知道静态化的朋友都不陌生,说白了就是访问后缀是html 而不是jsp. 没听说过静态 ...
- php页面静态化技术;学习笔记
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 基于 ThinkPHP 3.2.3 的页面静态化功能的实现
PHP 的页面静态化有多种实现方式,比如使用输出缓冲(output buffering),该种方式是把数据缓存在 PHP 的缓冲区(内存)中,下一次取数据时直接从缓冲区中读取数据,从而避免了脚本的编译 ...
随机推荐
- IOS 完成来电归属地
首先是一个库:(有时间在上传) 然后设置一个工具类 .h @interface HMFoundLocation : NSObject AS_SINGLETON(HMFoundLocation) @pr ...
- chrome - Vimium 插件超级方便快捷键
Vimium插件作用 安装后,可以用定义好的快捷键操作浏览器,好用到爆粗口 下载地址 https://chrome.google.com/webstore/detail/vimium/dbepggeo ...
- C#和Python 图片和base64的互转
C#实例代码: /// <summary> /// 图片转base64 /// </summary> /// <param name="bmp"> ...
- Java面向对象的三大特性 继承
继承是类与类的一种关系,是“is a"关系 子类拥有父类的属性和方法,private除外 class 子类 extends 父类 方法的重写 调用方法时会优先调用子类的方法 重写时,返 ...
- Centos下搭建nginx反向代理
上一节已经用编译的方式搭建好了一个nginx,链接在下面 https://www.toutiao.com/i6693130510777975300/ 然后这次我们把上次搭建好的nginx作为反向代理的 ...
- Mysql的子查询与连接查询
子查询: 在一个 select 语句中,嵌入了另外一个 select 语句, 那么被嵌入的 select 语句称之为子查询语句 主查询和子查询的关系: 子查询是嵌入到主查询中,子查询是辅助主查询的,要 ...
- Meissel Lehmer Algorithm 求前n个数中素数个数 【模板】
Count primes Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- js和css文件位置对页面性能的影响
翻译了一篇Performance上的关于页面性能的文章<DecIPhering the critical rendering path>,原文在这里.需要进一步整理和了解有关js.css等 ...
- JOS lab1 part2 分析
lab1的Exercise 2就是让我们熟悉gdb的si操作,并知道BIOS的几条指令在做什么就够了,所以我们也会尽可能的去分析每一行代码. 首先进入到6.8282/lab这个目录下,输入指令make ...
- ng2学习--pipe使用
We use our custom pipe the same way we use built-in pipes.(自定义Pipe和API里自带的Pipe使用方式一致) We must includ ...