小型社交平台,能发帖,查看帖子,评论帖子,删除帖子,删除评论等功能
- package com.iflysse.bbs.controller;
-
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
-
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- http://www.nvzi91.cn/niaodaoyan/29938.html
- import net.sf.json.JSONSerializer;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.ModelAttribute;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.SessionAttributes;
- import org.springframework.web.bind.support.SessionStatus;
- http://www.nvzi91.cn/yindaoyan/29939.html
- import com.alibaba.fastjson.JSON;
- import com.iflysse.bbs.dao.service.commentsService;
- import com.iflysse.bbs.dao.service.newsService;
- import com.iflysse.bbs.dao.service.usersService;
- import com.iflysse.bbs.model.comments;
- import com.iflysse.bbs.model.news;
- import com.iflysse.bbs.model.users;
- import com.iflysse.bbs.service.Impl.commentsServiceImpl;
- import com.iflysse.bbs.service.Impl.newsServiceImpl;
- import com.iflysse.bbs.service.Impl.usersServiceImpl;
- import com.sun.org.apache.xerces.internal.util.Status;
-
- @Controller
- @SessionAttributes({"user"})
- public class IndexController {
-
- @RequestMapping(value="index.do")
- public String index(ModelMap map){
- newsService ns = new newsServiceImpl();
- List<news> number = ns.getNews(1, Integer.MAX_VALUE);
- int count = number.size();
- int page = 0;
- if(count == 0){
- page = 1;
- }else{
- page = count%3 == 0 ? count/3 : (count/3) + 1;
- }http://www.nvzi91.cn/yindaoyan/29940.html
- List<news> lstn = ns.getNews(1, 3);
- map.addAttribute("page", page);
- map.addAttribute("index", 1);
- map.addAttribute("list", lstn);
- return "index";
- }
-
- @RequestMapping(value="search.do",method=RequestMethod.POST)
- public String search(String find, String pageIndex, ModelMap map){
- newsService ns = new newsServiceImpl();
- int index = Integer.valueOf(pageIndex);
- map.addAttribute("index", index);
- List<news> count = ns.getNews(1, Integer.MAX_VALUE);
- int number = count.size();
- int page = number%3 == 0 ? number/3 : (number/3) + 1;
- map.addAttribute("page", page);
- if (find == null) {
- List<news> ltn = ns.getNews(index, 3);
- map.addAttribute("list", ltn);
- } else {
- List<news> ltn = ns.getNewsByTitle(find, index, 3);
- map.addAttribute("list", ltn);
- }
- return "index";
- }http://www.nvzi91.cn/luanchaonanzhong/29941.html
-
- @RequestMapping(value="login.do",method=RequestMethod.GET)
- public String preLogin(){
- return "login";
- }
- http://m.nvzi91.cn/jiankang/29353.html
- @RequestMapping(value="login.do",method=RequestMethod.POST)
- public String afterLogin(String account,String password,ModelMap map){
- usersService us = new usersServiceImpl();
- users user = us.getUsersByAccPsw(account, password);
- if(user != null){
- map.addAttribute("user", user);
- return "redirect:index.do";
- }else{
- return "redirect:error.do";
- }
- }
- http://www.nvzi91.cn/zigongjiliu/29942.html
- @RequestMapping(value="view.do")
- public String vaiew(String id, ModelMap map){
- int newsid = Integer.valueOf(id);
- newsService ns = new newsServiceImpl();
- commentsService cs = new commentsServiceImpl();
- List<comments> lstc = cs.getCommentsByNewsId(newsid);
- news news = ns.getNewsByNewsId(newsid);
- map.addAttribute("news", news);
- map.addAttribute("comments", lstc);
- return "view";
- }http://m.nvzi91.cn/zigongai/29352.html
-
- @RequestMapping(value="comments.do")
- public String comment(@ModelAttribute("user")users user, String id, String content){
- if(user != null){
- int newsid = Integer.valueOf(id);
- comments comm = new comments(1,content,new Date(),user.getId(),newsid);
- commentsService cs = new commentsServiceImpl();
- cs.addComments(comm);
- return "redirect:view.do?id=" + id;
- }else{
- return "redirect:login.do";
- }
- }
- http://www.kmrlyy.com/fujianyan/33454.html
- @RequestMapping(value="error.do")
- public String error(){
- return "error";
- }
-
- @RequestMapping(value="logout.do")
- public String logout(@ModelAttribute("user")users user, SessionStatus status){
- if(user != null){
- status.setComplete();
- }
- return "redirect:index.do";
- }
-
- @RequestMapping(value="myindex.do")
- public String myidex(){
- return "personal/myindex";
- }
- http://www.kmrlyy.com/fujianyan/33455.html
- @RequestMapping(value="mynews.do",method=RequestMethod.GET)
- public String preMyNews(@ModelAttribute("user")users user, ModelMap map){
- int userid = user.getId();
- newsService ns = new newsServiceImpl();
- List<news> lstn = ns.getNewsByUserId(userid);
- map.addAttribute("news", lstn);
|