cms-详细信息页面设计
思路:点击主页面然后查询详细信信,把查询出来的数据放大modelandvie里面,然后返回前台,然后在跳转页面取出来显示;
代码:
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.ArticleDao">

<resultMap type="Article" id="ArticleResult">
<result property="id" column="id"/>
<result property="title" column="title"/>
<result property="publishDate" column="publishDate"/>
<result property="content" column="content"/>
<result property="summary" column="summary"/>
<result property="titleColor" column="titleColor"/>
<result property="click" column="click"/>
<result property="isRecommend" column="isRecommend"/>
<result property="isSlide" column="isSlide"/>
<result property="keyWords" column="keyWords"/>

<association property="arcType" column="typeId" select="com.open1111.dao.ArcTypeDao.findById"></association>
</resultMap>

<select id="getNewest" resultMap="ArticleResult">
select * from t_article order by publishDate desc limit 0,7
</select>

<select id="getRecommend" resultMap="ArticleResult">
select * from t_article where isRecommend=1 order by publishDate desc limit 0,7
</select>

<select id="getSlide" resultMap="ArticleResult">
select * from t_article where isSlide=1 order by publishDate desc limit 0,5
</select>

<select id="getIndex" parameterType="Integer" resultMap="ArticleResult">
select * from t_article where typeId=#{typeId} order by publishDate desc limit 0,8
</select>

<select id="findById" parameterType="Integer" resultMap="ArticleResult">
select * from t_article where id=#{id}
</select>

</mapper>

dao:
package com.open1111.dao;

import java.util.List;

import com.open1111.entity.Article;

/**
* 帖子Dao接口
* @author user
*
*/
public interface ArticleDao {

/**
* 获取最新的7条帖子
* @return
*/
public List<Article> getNewest();

/**
* 获取最新7条推荐的帖子
* @return
*/
public List<Article> getRecommend();

/**
* 获取最新5条幻灯的帖子
* @return
*/
public List<Article> getSlide();

/**
* 根据帖子类别来查找最新的8条数据
* @param typeId
* @return
*/
public List<Article> getIndex(Integer typeId);

/**
* 通过id查询帖子
* @param id
* @return
*/
public Article findById(Integer id);
}

service:
package com.open1111.service;

import java.util.List;

import com.open1111.entity.Article;

/**
* 帖子Service接口
* @author user
*
*/
public interface ArticleService {

/**
* 获取最新的7条帖子
* @return
*/
public List<Article> getNewest();

/**
* 获取最新7条推荐的帖子
* @return
*/
public List<Article> getRecommend();

/**
* 获取最新5条幻灯的帖子
* @return
*/
public List<Article> getSlide();

/**
* 根据帖子类别来查找最新的8条数据
* @param typeId
* @return
*/
public List<Article> getIndex(Integer typeId);

/**
* 通过id查询帖子
* @param id
* @return
*/
public Article findById(Integer id);
}

serviceImpl:

package com.open1111.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.open1111.dao.ArticleDao;
import com.open1111.entity.Article;
import com.open1111.service.ArticleService;

/**
* 帖子Service实现类
* @author user
*
*/
@Service("articleService")
public class ArticleServiceImpl implements ArticleService{

@Resource
private ArticleDao articleDao;

public List<Article> getNewest() {
return articleDao.getNewest();
}

public List<Article> getRecommend() {
return articleDao.getRecommend();
}

public List<Article> getSlide() {
return articleDao.getSlide();
}

public List<Article> getIndex(Integer typeId) {
return articleDao.getIndex(typeId);
}

public Article findById(Integer id) {
return articleDao.findById(id);
}

}

controller:package com.open1111.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.open1111.entity.Article;
import com.open1111.service.ArticleService;

/**
* 帖子Controller层
* @author user
*
*/
@Controller
@RequestMapping("/article")
public class ArticleController {

@Resource
private ArticleService articleService;

@RequestMapping("/{id}")
public ModelAndView details(@PathVariable("id") Integer id)throws Exception{
ModelAndView mav=new ModelAndView();
Article article=articleService.findById(id);
mav.addObject("article", article);
mav.setViewName("article");
return mav;
}

}

主页面:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Open1111官方网站 -南通小锋网络科技有限公司</title>
<META NAME="Author" CONTENT="Java1234_小锋老师">
<meta name="keywords"
content="Java内容管理系统,JavaCMS,Java开源,Java爬虫,JavaSEO,Java CMS" />
<meta name="description"
content="Open1111专注于研发Java建站,Java爬虫,JavaSEO教程.传授广大学员用Java技术来实现互联网资源的搬运,整合汇聚互联网资源建站,顺便获取一些搬运费补贴家用." />
<link rel="stylesheet"
href="${pageContext.request.contextPath}/static/css/open1111.css">
<script src="${pageContext.request.contextPath}/static/js/jQuery.js"></script>
</head>
<body>
<jsp:include page="/common/head.jsp"></jsp:include>
<jsp:include page="/common/menu.jsp"></jsp:include>

<div class="content">
<div class="w960">

<div class="left">
<DIV style="width: 330px; height: 228px;" class="tuhuo">
<A href="" target="_blank"><IMG
style="width: 330px; height: 208px;" id="fou_img" src=""></A>

<c:forEach var="article" items="${slideArticleList }">
<A
href="${pageContext.request.contextPath}/article/${article.id}.html">
<IMG style="display: none;" class="tu_img"
src="${pageContext.request.contextPath}/static/userImages/${article.slideImage}"
width="330" height="208" />
</A>
</c:forEach>

<c:forEach var="article" items="${slideArticleList }">
<P style="height: 20px;" class="tc">
<A
href="${pageContext.request.contextPath}/article/${article.id}.html"
target="_blank" title="${article.title }">${fn:substring(article.title,0,18) }</A>
</P>
</c:forEach>

<UL>
<LI class="fouce">1</LI>
<LI>2</LI>
<LI>3</LI>
<LI>4</LI>
<LI>5</LI>
</UL>
</DIV>

</div>

<div class="middle">

<div class="data_list">
<div class="dataHeader">最近更新</div>
<div class="datas">
<ul>
<c:forEach var="article" items="${newestArticleList }">
<li><a target="_blank"
href="${pageContext.request.contextPath}/article/${article.id}.html"
title="${article.title }">[<fmt:formatDate
value="${article.publishDate }" pattern="MM-dd" />]&nbsp;&nbsp;<font
color="${article.titleColor }">${fn:substring(article.title,0,20) }</font></a></li>
</c:forEach>
</ul>
</div>
</div>

</div>

<div class="right">
<div class="data_list">
<div class="dataHeader">站长推荐</div>
<div class="datas">
<ul>
<c:forEach var="article" items="${recommendArticleList }">
<li><a target="_blank"
href="${pageContext.request.contextPath}/article/${article.id}.html"
title="${article.title }"><font
color="${article.titleColor }">${fn:substring(article.title,0,16) }</font></a></li>
</c:forEach>

</ul>
</div>
</div>

</div>
</div>

<c:forEach var="subIndexArticleList" items="${allIndexArticleList }" varStatus="allStatus">
<c:if test="${allStatus.index%3==0 }">
<div class="w960 article_row">
</c:if>

<c:forEach var="indexArticle" items="${subIndexArticleList}" varStatus="oneStatus">
<c:if test="${oneStatus.first }">
<c:choose>
<c:when test="${allStatus.index%3==0 }">
<div class="data_list article_list">
</c:when>
<c:otherwise>
<div class="data_list article_list" style="margin-left: 12px">
</c:otherwise>
</c:choose>
<div class="dataHeader">
${arcTypeList.get(allStatus.index).typeName}<span class="more"><a href="${pageContext.request.contextPath}/arcType/${arcTypeList.get(allStatus.index).id}.html">更多...</a></span>
</div>
<div class="datas">
<ul>
</c:if>
<li>[<fmt:formatDate value="${indexArticle.publishDate }" pattern="MM-dd" />]&nbsp;&nbsp;<a target="_blank" href="${pageContext.request.contextPath}/article/${indexArticle.id }.html"
title="${indexArticle.title }"><font color="${indexArticle.titleColor }">${fn:substring(indexArticle.title,0,18) }</font></a></li>
<c:if test="${oneStatus.last }">
</ul>
</div>
</div>
</c:if>

</c:forEach>

<c:if test="${allStatus.index%3==2 || allStatus.last}">
</div>
</c:if>
</c:forEach>

</div>

<jsp:include page="/common/link.jsp"></jsp:include>

<jsp:include page="/common/foot.jsp"></jsp:include>
</body>
<script type="text/javascript">
var auto;
var index = 0;
$('.tuhuo ul li').hover(function() {
clearTimeout(auto);
index = $(this).index();
move(index);
}, function() {
auto = setTimeout('autogo(' + index + ')', 3000);
});

function autogo() {
if (index < 3) {
move(index);
index++;
} else {
index = 0;
move(index);
index++;
}
}
function move(l) {
var src = $('.tu_img').eq(index).attr('src');
$("#fou_img").css({
"opacity" : "0"
});
$('#fou_img').attr('src', src);
$('#fou_img').stop(true).animate({
opacity : '1'
}, 1000);
$('.tuhuo ul li').removeClass('fouce');
$('.tuhuo ul li').eq(index).addClass('fouce');
$('.tuhuo p').hide();
$('.tuhuo p').eq(index).show();
var ao = $('.tuhuo p').eq(index).children('a').attr('href');
$('#fou_img').parent('a').attr("href", ao);
}
autogo();
setInterval('autogo()', 3000);
</script>

</html>

目标页面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${article.title }_Open1111官方网站 -南通小锋网络科技有限公司</title>
<META NAME="Author" CONTENT="Java1234_小锋老师">
<meta name="keywords"
content="${article.keyWords }" />
<meta name="description"
content="${article.summary }" />
<link rel="stylesheet"
href="${pageContext.request.contextPath}/static/css/open1111.css">
<script src="${pageContext.request.contextPath}/static/js/jQuery.js"></script>
</head>
<body>
<jsp:include page="/common/head.jsp"></jsp:include>
<jsp:include page="/common/menu.jsp"></jsp:include>

<div class="content">
<div class="w960">
<div class="pLeft">
<div class="article_title"><h2><strong>${article.title }</strong></h2></div>
<div class="article_content">
${article.content }
</div>
</div>

<div class="pRight">
</div>
</div>
</div>

<jsp:include page="/common/foot.jsp"></jsp:include>
</body>
</html>

cms-详细页面-1的更多相关文章

  1. magento在产品详细页面添加分享链接的方法

    1,在产品详细页面的对用位置加入一下代码 <div class="sharethis_box">          <?php echo $this->ge ...

  2. ios 类似的效果淘宝商品详细页面

    今天试着写ios 分类似影响淘宝的商品详细页面 我使用第三方库EGORefreshTableHeaderView有一个下拉效果刷新PWLoadMoreTableFooterView上拉电阻负载许多其他 ...

  3. 阶段5 3.微服务项目【学成在线】_day09 课程预览 Eureka Feign_14-课程预览功能开发-CMS添加页面接口

    5.3 CMS添加页面接口 cms服务对外提供添加页面接口,实现:如果不存在页面则添加,否则就更新页面信息. 此接口由课程管理服务在课程预览时调用. 接口方法.:页面没有就添加.有了更新数据 之前的接 ...

  4. 帝国CMS自定义页面的添加与目录式链接的处理

    需求: 1.将某一本地前端自定义页面模板,导入到帝国系统,应用到网站 2.将导入的页面在站点中打开为目录式链接 www.abc.com/softlink/ 环境: 1.windows服务器 2.帝国C ...

  5. 通过SPList Definition自定义ListItem打开编辑详细页面

    在SharePoint中对列表SPList的操作里,常常希望当增加一个条目后还希望关联做一些其它的操作 而SharePoint自身提供的Item操作页面却没有那么灵活:所以通常情况下,我们专门为其提供 ...

  6. zencart产品详细页面调用数据库显示tags标签

      给商品信息页面添加一些tag关键词标签有利于谷歌的收录,也有利于关键词的SEO,实现这个功能并不难.其实就是给zencart添加一个功能模块, 具体方法是: 1,在mudules目录下面新建一个以 ...

  7. 如何修改magento产品详细页面的栏目

    magento默认模板里面的产品信息页面的布局是以两栏带右侧栏显示的,那么如何修改为两栏带左侧栏或者三栏.一栏的方式显示呢?下面教大家一种很简单的方法就可以实现.下面是默认的布局预览:

  8. *ecsho 的商品详细页面上获取该商品的一级分类ID及NAME

    1.打开goods.php并找到 $smarty->assign('goods', $goods); 在它上面增加以下代码 $cat_arr = get_parent_cats($goods[' ...

  9. ECSHOP在商品详细页面上获取该商品的顶级分类id和名称

    在 goods.php 文件, 找到 $smarty->assign('goods', $goods); 在它上面增加下面代码: 方法一: $cat_arr = get_parent_cats( ...

  10. IOS开发---菜鸟学习之路--(十)-实现新闻详细信息浏览页面

    前面已经将了上下拉刷新 实现了上下拉刷新后我们的第一级界面就做好,接下来我们就需要实现 新闻详细信息浏览了 我个人认为一般实现新闻详细页面的方法有两种(主要是数据源的不同导致了方法的不同) 第一种是本 ...

随机推荐

  1. 【转】ANT安装、环境变量配置及验证

    http://www.cnblogs.com/yuzhongwusan/archive/2013/03/26/2982411.html Posted on 2013-03-26 14:01 yuzho ...

  2. [WPF自定义控件]从ContentControl开始入门自定义控件

    1. 前言 我去年写过一个在UWP自定义控件的系列博客,大部分的经验都可以用在WPF中(只有一点小区别).这篇文章的目的是快速入门自定义控件的开发,所以尽量精简了篇幅,更深入的概念在以后介绍各控件的文 ...

  3. wxpython实现文件拖拽

    我想让wx.grid里面的单元格能够支持文件拖拽,实现起来挺简单的,共分3步: 1.创建一个wx.FileDropTarget子类的对象,并把要支持拖拽的控件传给它的构造函数,此处是grid 2.调用 ...

  4. bzoj4373:算数天才与等差数列

    算术天才⑨非常喜欢和等差数列玩耍. 有一天,他给了你一个长度为n的序列,其中第i个数为a[i]. 他想考考你,每次他会给出询问l,r,k,问区间[l,r]内的数从小到大排序后能否形成公差为k的等差数列 ...

  5. oracle 重做日志

    原创转载请注明出处 重做日志:记录数据库数据的变化(DDL,DML) 重做日志组:由一个或者多个完全一样的重做日志文件组成,如果一个日志组有多个日志文件,后台进程LGWR会把事务变化写到同一个日志组的 ...

  6. dorado 常用

    如果要设置模糊查询, 一般要在QueryCommand中这样写: var name = dsQuery.getValue("NAME"); var parameters = com ...

  7. [USACO07MAR]黄金阵容均衡Gold Balanced L… map

    题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to na ...

  8. EcmaScript内置对象的属性与方法

  9. Linux之数据库

    crm 1.一定得会用linux发行版 centos 熟悉各种linux命令 2.你的确保linux服务器可以上网 , 一定得有ip地址,且确保dns解析正常 /etc/resolv.conf 3.上 ...

  10. 1、python简单介绍

    写在前面:曾经与java擦肩而过,现在懊悔很深,希望自己通过学习python,熟练掌握python,来弥补曾经的愚蠢.python简单介绍 python 1989年年底诞生,截止2017年,已经是IT ...