XXXController.java

package com.hp.Controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
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.hp.domain.Feed;
import com.hp.domain.User;
import com.hp.service.FeedService;

@Controller
public class FeedController {
    @Autowired
    private FeedService feedService;
    ModelAndView mode = new ModelAndView();
    //显示
    @RequestMapping("/findselect")
    public ModelAndView findselect(Feed feed,HttpSession session)
    {
        String uname = (String)session.getAttribute("uname");
        feed.setUname(uname);
        mode.addObject("eistList",feedService.eist());
        mode.addObject("findselectList", feedService.findselect(feed));
        mode.setViewName("index");
        return mode;
    }
    //登录
    @RequestMapping("/login")
    public ModelAndView login(User user,HttpSession session)
    {
        User u = feedService.login(user);
        if(u!=null)
        {
            Integer id = feedService.findUser(user.getUname());
            session.setAttribute("id", id);
            System.out.println(id);
            session.setAttribute("uname", user.getUname());
            mode.setViewName("redirect:/findselect");
        }
        else
        {
            mode.setViewName("login");
        }
        return mode;
    }
    //删除
    @RequestMapping("/del/{id}")
    public ModelAndView del(@PathVariable Integer id)
    {
        feedService.del(id);
        mode.setViewName("redirect:/findselect");
        return mode;
    }
    //新增带参回显
    @RequestMapping("/toadd")
    public ModelAndView toadd(HttpSession session)
    {
        String uname = (String)session.getAttribute("uname");
        Integer id = (Integer)session.getAttribute("id");
        mode.addObject("uname",uname);
        mode.addObject("id",id);
        mode.setViewName("add");
        return mode;
    }
    //新增
    @RequestMapping("/add")
    public ModelAndView add(Feed feed)
    {
        feedService.add(feed);
        mode.setViewName("redirect:/findselect");
        return mode;
    }
    //修改公开和不公开
    @RequestMapping("/update/{id}")
    public ModelAndView update(@PathVariable Integer id)
    {
        feedService.update(id);
        mode.setViewName("redirect:/findselect");
        return mode;
    }
}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值