首页>代码>spring mvc+spring+hibernate开发简单的java bbs论坛系统,适合二次开发>/Forum/src/com/baidu/controller/MainBoardController.java
package com.baidu.controller;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.baidu.entity.MainBoard;
import com.baidu.entity.Post;
import com.baidu.service.ChildBoardService;
import com.baidu.service.MainBoardService;
import com.baidu.service.PostService;
import com.baidu.util.ConstantPageURL;
@Controller
public class MainBoardController {
@Autowired
private MainBoardService mainBoardService;
@Autowired
private ChildBoardService childBoardService;
@Autowired
private PostService postService;
@RequestMapping("/index")
public String toIndex(Model model){
//查询主板块 集合
List<MainBoard> list = mainBoardService.findAllAndChild();
model.addAttribute("mainBoardList",list);//request保存
return ConstantPageURL.INDEX_PAGE;
}
@RequestMapping("/manager/mainBoard")
@ResponseBody
public List findAllMainBoard(){
//查询主板块 集合
List<MainBoard> list = mainBoardService.findAll();
return list;
}
@RequestMapping("/showPost")
public String toShowPost(int id,String boardName ,Model model){
System.out.println("id:"+id);
//根据id查询该子版块下的帖子集合
List<Post> list = this.postService.findPostByBoardId(id);
//根据id更新该子版块记录的 点击数 +1
this.childBoardService.updateReadCount(id);
//保存帖子集合
model.addAttribute("postList", list);
try {
//boardName = new String(boardName.getBytes("iso-8859-1"),"UTF-8");
boardName = URLDecoder.decode(boardName, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
model.addAttribute("boardName", boardName);//子版块名字
//跳转
return ConstantPageURL.SHOW_POST_PAGE;
}
}
最近下载更多
wouldbb LV6
2023年3月25日
yanghanqiang LV3
2023年2月17日
1342203642 LV10
2023年1月18日
超炫爱 LV2
2022年12月5日
molu123456
2022年11月15日
暂无贡献等级
yazhiyjs LV4
2022年8月30日
拂袖云中 LV4
2022年6月17日
微信网友_5916966536499200 LV2
2022年4月15日
wanglinddad LV55
2022年3月24日
你好啊李光庚 LV1
2022年3月21日
最近浏览更多
6418368 LV10
8月5日
月牙君 LV1
4月25日
ChanLain LV2
3月3日
123123123W LV7
2024年1月22日
空中飞尘 LV13
2023年12月13日
1383838438 LV1
2023年11月15日
微信网友_6465435620184064 LV7
2023年10月24日
asssasa LV1
2023年10月17日
唐钰小宝A LV13
2023年9月12日
山东老马
2023年7月7日
暂无贡献等级

