Example usage for org.springframework.web.servlet ModelAndView setViewName

List of usage examples for org.springframework.web.servlet ModelAndView setViewName

Introduction

In this page you can find the example usage for org.springframework.web.servlet ModelAndView setViewName.

Prototype

public void setViewName(@Nullable String viewName) 

Source Link

Document

Set a view name for this ModelAndView, to be resolved by the DispatcherServlet via a ViewResolver.

Usage

From source file:io.uengine.web.system.UserController.java

/**
 * ? ??  ./*from w  ww.  j  a v  a 2s. co m*/
 */
@RequestMapping(value = "/repasswdProc", method = RequestMethod.POST)
@Secured({ "ROLE_ADMIN", "ROLE_USER" })
public ModelAndView changePassword(@RequestParam String password, @RequestParam String newPassword,
        @RequestParam String confirmNewPassword) {
    String email = SessionUtils.getEmail();

    //  ? 
    if (!passwordEncoder.matches(password, SessionUtils.getPasswd())) {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("/auth/invalidPasswd");
        return mav;
    }

    Map map = new HashMap();
    map.put("email", email);
    map.put("password", passwordEncoder.encode(newPassword));
    userService.updatePassword(map);

    ModelAndView mav = new ModelAndView();
    mav.setViewName("/auth/passwdChanged");
    return mav;
}

From source file:edu.bbu.security.web.controllers.MainController.java

@RequestMapping(value = "/admin**", method = RequestMethod.GET)
public ModelAndView adminPage() {
    System.out.println("lofasz admin");
    ModelAndView model = new ModelAndView();
    model.addObject("title", "Spring Security Custom Login Form");
    model.addObject("message", "This is protected page!");
    model.setViewName("admin");

    return model;

}

From source file:io.uengine.web.system.UserController.java

@RequestMapping(value = "/passwdConfirm", method = RequestMethod.GET)
public ModelAndView confirm(HttpServletResponse res, @RequestParam String userid, @RequestParam String token)
        throws IOException {
    long tokenTimestamp = Long.parseLong(new String(Base64.decodeBase64(token)));
    if (DateUtils.getDiffDays(new Date(), new Date(tokenTimestamp)) > 1) {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("/auth/error-401");
        return mav;
    }//w w w. j av  a 2 s .c om
    try {
        if (userService.reqPasswdExist(userid, token)) {
            ModelAndView mav = new ModelAndView();
            mav.setViewName("/auth/repasswd");
            return mav;
        } else {
            ModelAndView mav = new ModelAndView();
            mav.setViewName("/auth/error-401");
            return mav;
        }
    } catch (Exception ex) {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("/auth/error-401");
        return mav;
    }
}

From source file:com.bsg.pcms.provision.contract.ContractController.java

@RequestMapping(value = "create", method = RequestMethod.GET)
public ModelAndView create() {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("contract-info");
    mav.addObject("leftMenuSeq", bigstarConstant.LEFT_CONTRACTS);
    mav.addObject("navSeq", bigstarConstant.HEADER_CP);
    mav.addObject("isCreate", 1);

    mav.addObject("cpList", cpService.getCpListAll());
    mav.addObject("bankList", bankListMaker.getBankList());

    List<CodeDTO> contractTypeList = _codeService.contractTypeList();
    List<CodeDTO> licenseList = _codeService.licenseList();
    mav.addObject(bigstarConstant.OB_CONTRACT_TYPE_LIST, contractTypeList);
    mav.addObject(bigstarConstant.OB_LICENSE_LIST, licenseList);

    return mav;/*  w  ww.j  a  v  a2 s  . c o m*/

}

From source file:com.healthcit.cacure.web.controller.admin.GenerateSampleDataController.java

@RequestMapping(value = Constants.GENERATE_SAMPLE_DATA_URI, method = RequestMethod.POST)
public ModelAndView submitForm(@ModelAttribute GeneratedModuleDataDetail formDetail) {
    log.debug("In submitForm method...");

    ModelAndView modelAndView = new ModelAndView();

    modelAndView.setViewName("generateSampleDataConfirm");

    try {//ww w  .j  a  va  2  s. co  m
        dataManager.generateSampleDataInCouchDB(formDetail);

        modelAndView.getModelMap().put("tracker", formDetail.getTracker());

        modelAndView.getModelMap().put("numModulesGenerated", formDetail.getActualNumberOfModules());

        modelAndView.getModelMap().put("numEntitiesGenerated", formDetail.getActualNumberOfEntities());

        modelAndView.getModelMap().put("numDocumentsGenerated", formDetail.getActualNumberOfCouchDbDocuments());
    } catch (Exception ex) {
        ex.printStackTrace();
        //TODO: Display error messages as appropriate
    }

    return modelAndView;
}

From source file:com.rr.wabshs.ui.resources.resourcesController.java

/**
 * The 'resourceList' GET request will return the main program resource list page.
 * /*w ww.  java2s  .  c o  m*/
 * @param session
 * @return
 * @throws Exception 
 */
@RequestMapping(value = "/skillSetList", method = RequestMethod.GET)
public ModelAndView resourceList(HttpSession session) throws Exception {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("/resources");

    return mav;

}

From source file:ilearn.orb.controller.AnalysisController.java

@RequestMapping(value = "/analysis")
public ModelAndView textAnalysis(Locale locale, ModelMap modelMap, HttpServletRequest request,
        HttpSession session) {/*from  w w  w . j  a  va 2s  .  c  o  m*/
    try {
        request.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }
    ModelAndView model = new ModelAndView();
    model.setViewName("analysis");

    try {
        Gson gson = new GsonBuilder().registerTypeAdapter(java.util.Date.class, new UtilDateDeserializer())
                .setDateFormat(DateFormat.LONG).create();
        User[] students = null;
        try {
            String json = UserServices.getProfiles(Integer.parseInt(session.getAttribute("id").toString()),
                    session.getAttribute("auth").toString());
            students = gson.fromJson(json, User[].class);
        } catch (NullPointerException e) {
        }
        if (students == null || students.length == 0) {
            students = HardcodedUsers.defaultStudents();
        }
        modelMap.put("students", students);
        String text = request.getParameter("inputText");
        String profileId = request.getParameter("selectedId");
        if (text != null) {
            text = new String(text.getBytes("8859_1"), "UTF-8");
        } else
            text = "";
        modelMap.put("profileId", profileId);
        modelMap.put("text", text);
        String json;
        if (Integer.parseInt(profileId) > 0)
            json = TextServices.getAnalysisJson(Integer.parseInt(profileId),
                    session.getAttribute("auth").toString(), text);
        else
            json = TextServices
                    .getAnalysisJson(HardcodedUsers.defaultProfileLanguage(Integer.parseInt(profileId)), text);
        AnalysisResults analysisResults = null;
        analysisResults = (new Gson()).fromJson(json, AnalysisResults.class);
        modelMap.put("analysisResults", analysisResults);
        UserProfile pr = retrieveProfile(session, Integer.parseInt(profileId));
        modelMap.put("selectedProfile", pr);
        int maxWordsMatched = 0;
        for (int i = 0; i < pr.getUserProblems().getNumerOfRows(); i++) {
            for (int j = 0; j < pr.getUserProblems().getRowLength(i); j++) {
                if (analysisResults.getUserCounters().getValue(i, j) > maxWordsMatched)
                    maxWordsMatched = analysisResults.getUserCounters().getValue(i, j);
            }
        }
        modelMap.put("maxWordsMatched", maxWordsMatched);

    } catch (NumberFormatException e) {
        //e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return model;

}

From source file:com.showcase.mobile.AboutController.java

/**
 * Show the About page to the user./*from  ww w  .ja  va  2 s  .com*/
 * Declares a {@link SitePreference} parameter to show how you can resolve the user's site preference.
 * This controller renders a different version of the home view if the user has a mobile site preference.
 */
@RequestMapping("/about")
public ModelAndView about(HttpServletRequest servletRequest) {
    logger.info("about");
    ModelAndView mav = new ModelAndView();

    /*Device currentDevice = DeviceUtils.getCurrentDevice(servletRequest);
    mav.addObject("currentDevice", currentDevice.toString());*/

    mav.setViewName("home");
    return mav;
}

From source file:com.bitranger.parknshop.visitor.controller.ProductsCtrl.java

@RequestMapping(value = VisitorView.itemCtrlMapping, method = RequestMethod.GET)
public ModelAndView product(HttpServletRequest request, HttpServletResponse response) {

    List<PsItem> itemList = itemFinderService.getItems(request);
    System.out.println("ProductsCtrl.product()");
    System.out.println(itemList);
    for (PsItem psItem : itemList) {
        psItem.setIntroduction(Utility.slice(psItem.getIntroduction(), 40));
    }/* w  w  w  . ja  v a 2s . c  o  m*/

    ModelAndView mv = new ModelAndView();
    mv.addObject(VisitorParams.productItemList, itemList);
    mv.addObject(VisitorParams.itemCount, itemList.size());
    mv.setViewName(VisitorView.product);

    List<PsPromotItem> ads = adCenter.itemAdService.forItemList(itemList, 60, null);
    mv.addObject("ad_list", ads);

    return mv;

}

From source file:com.bsg.pcms.provision.contract.ContractController.java

@RequestMapping(value = "list", method = RequestMethod.GET)
public ModelAndView list(ContractDTOEx contractDTOEx) {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("contract-list");
    mav.addObject("leftMenuSeq", bigstarConstant.LEFT_CONTRACTS);
    mav.addObject("navSeq", bigstarConstant.HEADER_CP);

    contractDTOEx.setStartRownum((contractDTOEx.getPageNum() - 1) * pageUtil.getPerPage());
    mav.addObject("contractList", contractService.getContractList(contractDTOEx));
    mav.addObject("bankList", bankListMaker.getBankList());

    int totalCnt = contractService.getContractListCount(contractDTOEx);
    int pageNum = contractDTOEx.getPageNum();
    mav.addObject("pageLink", pageUtil.setPageLinkDTO(totalCnt, pageNum));
    //? prev/next  parameter
    if (contractDTOEx.getType() != null) {
        contractDTOEx.setSearch("&type=" + contractDTOEx.getType() + "&query=" + contractDTOEx.getQuery());
    }/*from w  ww. jav a  2 s .c  o  m*/
    mav.addObject("search", contractDTOEx);

    return mav;
}