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 的缓冲区(内存)中,下一次取数据时直接从缓冲区中读取数据,从而避免了脚本的编译 ...
随机推荐
- 聪明的kk (南洋理工—171)
#include<iostream> using namespace std; ][]; ][]; int N, M; int dp(int i, int j) { ) return d[ ...
- c++第四次实验2
Part 1 车辆基本信息管理 1.代码 #include<iostream> using namespace std; #include"car.h" #includ ...
- 如何给自己的开源项目选择和添加 License
License 的作用:开源 == 为所欲为? 开源并不等于为所欲为! 代码的用途,修改之后的代码有什么要求,开源程序对于原作者的权利和责任等等,都是需要明确的. 开源协议 License 就是这么一 ...
- 洛谷P2258 子矩阵
P2258 子矩阵 题目描述 给出如下定义: 子矩阵:从一个矩阵当中选取某些行和某些列交叉位置所组成的新矩阵(保持行与列的相对顺序)被称为原矩阵的一个子矩阵. 例如,下面左图中选取第2.4行和第2.4 ...
- Eclipse项目中乱码问题的解决办法
一.产生的原因: 1.Http协议进行通信的时候是基于请求和响应的,传输的内容我们称之为报文! 2.Http协议会按照一定的规则将报文编码,然后在读取的时候再使用响应的解码格式进行解码! 3.这个一定 ...
- Angular输入框内按下回车会触发其它button的点击事件的解决方法
方法:给button按钮添加type=“botton”属性
- springBoot2.0 配置shiro实现权限管理
一.前言 基于上一篇springBoot2.0 配置 mybatis+mybatisPlus+redis 这一篇加入shiro实现权限管理 二.shiro介绍 2.1 功能特点 Shiro 包含 10 ...
- rest get post 请求工具_restclient.jar
下载 :restclient.jar 启动命令 : java -jar restclient.jar 界面如图所示:
- 去除 Git 安装后的右键菜单
64位 windows 8.1 安装 Git 后,右键菜单多了3个选项(Git Init Here,Git Gui, Git Bash),但是用不着,需要删掉.方法如下: 1.在 CMD 中进入 Gi ...
- java 核心技术 读后总结
总结 1.少用八进制,以及二进制. 那么就是直接用16进制或10进制吗?额,想当年有这样搞过,后面就uuid了. 2.>>>用0填充高位>>用符号位填充高位<< ...