Java 类org.springframework.web.bind.annotation.SessionAttribute 实例源码

项目:training-brainmatics-2016-01    文件:KelasController.java   
@PreAuthorize("hasRole('EDIT_MATERI')")
@RequestMapping(value = "form", method = RequestMethod.POST)
public String prosesForm(@ModelAttribute @Valid Kelas kelas, 
        BindingResult hasilValidasi, 
        SessionStatus status,
        @SessionAttribute(name = "daftarMateri") List<Materi> daftarMateri,
        @SessionAttribute(name = "daftarPeserta") List<Peserta> daftarPeserta
        ) {
    if(hasilValidasi.hasErrors()) {
        return "/kelas/form";
    }

    kelas.setDaftarMateri(daftarMateri);
    kelas.setDaftarPeserta(daftarPeserta);
    kd.save(kelas);
    status.setComplete();

    return "redirect:list";
}
项目:ACManager    文件:ContestController.java   
@RequestMapping("/modify/{contestId}")
public String modify1(Model model,
                      @PathVariable Integer contestId,
                      @SessionAttribute Integer stageId,
                      @SessionAttribute(required = false) User user,
                      RedirectAttributes redirectAttributes) {
    if(user == null || !user.isAdmin()) {
        redirectAttributes.addFlashAttribute("tip", "没有权限!");
        return "redirect:/training/stage/" + stageId;
    }
    Contest contest = trainingService.getContest(contestId);
    model.addAttribute("contestId", contestId);
    model.addAttribute("preContest", contest);
    model.addAttribute("stageId", stageId);
    return "importComp";
}
项目:programmeren3    文件:CartController.java   
@GetMapping("/checkout")
public ModelAndView balance(@SessionAttribute int items) {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.setViewName("showCheckout");
    modelAndView.getModel().put("totalPrice", items * 50);
    return modelAndView;
}
项目:ACManager    文件:UserACController.java   
@RequestMapping(value = "/updatedb", produces = "text/html;charset=UTF-8")
@ResponseBody
public String updatedb(@SessionAttribute(required = false) User user) {
    if(user == null){
        return "您没有登录";
    }
    if(user.isAdmin()){
        extOjService.flushACDB();
    }
    else{
        extOjService.flushACDByUser(user);
    }
    return "更新完毕,久等了......";
}
项目:ACManager    文件:ContestController.java   
@RequestMapping("/add1/{stageId}")
public String add1(Model model,
                   @PathVariable Integer stageId,
                   @SessionAttribute(required = false) User user,
                   RedirectAttributes redirectAttributes) {
    if(user == null || !user.isAdmin()) {
        redirectAttributes.addFlashAttribute("tip", "没有权限!");
        return "redirect:/training/stage/" + stageId;
    }
    model.addAttribute("contestId", -1);
    model.addAttribute("stageId", stageId);
    return "importComp";
}
项目:ACManager    文件:ContestController.java   
@RequestMapping("/deleteContest/{id}")
public String deleteContest(@PathVariable Integer id,
                            @SessionAttribute Integer stageId) {
    logger.info("收到删除比赛请求:{}", id);
    trainingService.deleteContest(id);
    return "redirect:/training/stage/" + stageId;
}
项目:ACManager    文件:StatisticController.java   
@RequestMapping(value = "/updateCFBC", produces = "text/html;charset=UTF-8")
@ResponseBody
public String updateCFBC(@SessionAttribute(required = false) User user) {
    System.out.println(user.getBcname());
    if(user == null)
        return "您没有登录!";
    if(user.isACMer()){

    }
    else{
        if(user.getBcname()!=null){
            synchronized (this) {
                cfbcService.flushBCUserInfoByName(user.getBcname());
            }
        }
        if(user.getCfname()!=null){
            synchronized (this) {
                //cfbcService.flushCFUserInfoByName(user.getCfname());
            }
        }
    }
    synchronized (this) {
        cfbcService.flushCFUserInfos();
        cfbcService.flushBCUserInfos();
    }
    return "恭喜,更新完毕!";
}
项目:training-brainmatics-2016-01    文件:KelasController.java   
@PreAuthorize("hasRole('EDIT_MATERI')")
@RequestMapping(value = "form", method = RequestMethod.GET)
public void tampilkanForm(
        @RequestParam(name = "id", required = false) Kelas kelas,
        @RequestParam(name = "id_materi", required = false) Materi materi,
        @RequestParam(name = "id_peserta", required = false) Peserta peserta,
        @RequestParam(name = "action", required = false) String action,
        @SessionAttribute(name = "daftarMateri", required = false) List<Materi> daftarMateri,
        @SessionAttribute(name = "daftarPeserta", required = false) List<Peserta> daftarPeserta,
        ModelMap mm) {

    if ("edit".equalsIgnoreCase(action)) {
        daftarMateri = new ArrayList<>();
        daftarPeserta = new ArrayList<>();
    }

    if (kelas != null) {
        mm.addAttribute("kelas", kelas);

        if("edit".equalsIgnoreCase(action)){
            daftarMateri = kelas.getDaftarMateri();
            daftarPeserta = kelas.getDaftarPeserta();
        }

    } else {
        mm.addAttribute("kelas", new Kelas());
    }

    if (materi != null) {
        if("add".equalsIgnoreCase(action)) {
            daftarMateri.add(materi);
        } else if("remove".equalsIgnoreCase(action)) {
            daftarMateri.remove(materi);
        } 
    }

    if (peserta != null) {
        if("add".equalsIgnoreCase(action)) {
            daftarPeserta.add(peserta);
        } else if("remove".equalsIgnoreCase(action)) {
            daftarPeserta.remove(peserta);
        } 
    }

    mm.addAttribute("daftarMateri", daftarMateri);
    mm.addAttribute("daftarPeserta", daftarPeserta);
}
项目:ACManager    文件:ContestController.java   
@RequestMapping("/importContest")
public String importContest(@RequestParam Integer contestId,
                            @RequestParam String contestName,
                            @RequestParam String contestType,
                            @RequestParam String stTime,
                            @RequestParam String edTime,
                            @RequestParam String source,
                            @RequestParam String sourceDetail,
                            @RequestParam String sourceUrl,
                            @RequestParam(required = false, defaultValue = "") String myConfig,
                            @RequestParam String vjContest,
                            @RequestParam(required = false, defaultValue = "false") Boolean realContest,
                            @RequestParam Integer stageId,
                            @SessionAttribute User user,
                            RedirectAttributes redirectAttributes) {
    logger.info("导入/修改比赛。。。");
    logger.info("contestId = [" + contestId + "], contestName = [" + contestName + "], contestType = [" + contestType + "], stTime = [" + stTime + "], edTime = [" + edTime + "], source = [" + source + "], sourceDetail = [" + sourceDetail + "], sourceUrl = [" + sourceUrl + "], myConfig = [" + myConfig + "], vjContest = [" + vjContest + "], user = [" + user + "], stageId = [" + stageId + "]");
    try {
        Contest contest = trainingService.parseVj(contestName, contestType, stTime, edTime,
                source, sourceDetail, sourceUrl, myConfig, vjContest, realContest, user, stageId);
        logger.info("比赛ID:{}", contestId);
        if(contestId == -1) {
            trainingService.saveContest(contest);
            redirectAttributes.addFlashAttribute("tip", "添加成功!");
        } else {
            Contest pre = trainingService.getContest(contestId);
            logger.info("修改比赛:原:{}", pre);
            contest.setId(contestId);
            contest.setAddTime(pre.getAddTime());
            contest.setAddUid(pre.getAddUid());
            contest.setStage(pre.getStage());
            logger.info("修改比赛:现:{}", contest);
            trainingService.saveContest(contest);
            redirectAttributes.addFlashAttribute("tip", "修改成功!");
        }
        return "redirect:/training/stage/" + stageId;
    } catch (IOException e) {
        e.printStackTrace();
    }
    redirectAttributes.addFlashAttribute("tip", "添加失败!");
    return "redirect:/training/stage/" + stageId;
}