首页>代码>s2sh框架开发的java web个人博客系统,基于maven搭建>/main/java/top/wull/blog/action/IndexAction.java
package top.wull.blog.action;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;

import top.wull.blog.antity.Essay;
import top.wull.blog.service.EssayService;
import top.wull.blog.service.EssayTypeService;
import top.wull.blog.service.MoodService;
import top.wull.blog.service.MusicService;
import top.wull.blog.util.PageBean;
@Controller("indexAction")
@Scope("prototype")
public class IndexAction extends BaseAction {
	/*
	 * 写在dao里面的方法,连续运行十几次就不行了,不知道为什么
	 * */
	@Resource(name="essayService")
	EssayService  es ;
	@Resource(name="moodService")
	MoodService  ms ;
	Essay e = new Essay();
	private Integer currentPage = 1;
	private Integer pageSize = 6;
	@Resource(name="musicService")
	MusicService  mus ;
	public Integer getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}
	public String life(){
		return "life";
	}
	
	public String list() throws Exception {
		//根据条件以及开始结束下标查询数据
		 // List<T> list = this.xxxService().find(cri,start, size);
		//封装离线查询对象  离线查询不需要sessionFactory 但是api方法比价少 比如取前n个
		
		//判断并封装参数
		//dc.add(Restrictions.isNotNull("recommend"));//推荐的文章
		//dc.addOrder(Order.asc("recommend"));
		//1 调用Service查询分页数据(PageBean)
		//PageBean pb = es.getPageBean(dc,currentPage,pageSize);
		PageBean pb = es.getPageBean(currentPage,6);
		
		//2 将PageBean放入request域,转发到列表页面显示
		/*Map<String, Object> data = new HashMap<>();
		data.put("news", news());
		data.put("newEssaylist", newEssaylist(8));
		data.put("showMaxCountEssay", showMaxCountEssay());
		data.put("pageBean", pb);
		ActionContext.getContext().put("data", data);			
		*/
		//ActionContext.getContext().put("news", news());			
		ActionContext.getContext().put("news", newEssaylist(6));			
		ActionContext.getContext().put("newEssaylist", newEssaylist(8));			
		ActionContext.getContext().put("showMaxCountEssay", showMaxCountEssay());		
		ActionContext.getContext().put("pageBean", pb);
		ActionContext.getContext().put("music", getRandomMusicUrl());
		
		System.out.println("dddddd");
		return "list";
	}
	
	String getRandomMusicUrl(){
		return mus.getRandomMusicUrl();
	}
	//主页的最新动态
	public List news(){
		//封装离线查询对象
		/*DetachedCriteria dc = DetachedCriteria.forClass(Essay.class);
		//1 调用Service查询分页数据(PageBean)
		PageBean pb = es.getPageBean(dc,1,6);
		return pb.getList();*/
		//ms.getNews(6);
		return null;
		
	}

}
最近下载更多
and123456  LV11 2022年3月16日
wjh12345654321  LV14 2022年1月20日
864152530  LV5 2021年6月7日
iws2000  LV11 2021年5月20日
myzczx  LV25 2021年4月9日
李海洋  LV12 2020年12月24日
lstudents  LV1 2020年8月20日
wllwll  LV4 2020年7月19日
kuluohua  LV15 2020年6月14日
1224649005  LV6 2020年6月5日
最近浏览更多
abandan  LV4 2023年11月6日
zhaobing_g  LV3 2023年8月28日
tangyongheng08  LV6 2023年7月24日
getset  LV8 2023年5月18日
acid6161 2023年4月21日
暂无贡献等级
lyhlyh  LV10 2023年2月24日
暂无贡献等级
yohohero  LV1 2023年1月14日
zxc131313  LV12 2022年12月9日
sweetlove  LV17 2022年11月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友