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

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

Introduction

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

Prototype

public ModelAndView addObject(String attributeName, @Nullable Object attributeValue) 

Source Link

Document

Add an attribute to the model.

Usage

From source file:bc8.movies.controllers.LoginController.java

@RequestMapping(value = "/logout")
public ModelAndView logout(HttpSession session) {
    ModelAndView mv = new ModelAndView("redirect:/home");
    mv.addObject("message", "Logged out!");
    session.invalidate();/*from w w  w . j  a v  a 2  s.c  om*/

    return mv;
}

From source file:com.huan.controller.MainPageController.java

@RequestMapping(value = "about", method = RequestMethod.GET)
public ModelAndView about() {
    ModelAndView modelAndView = new ModelAndView("about");
    modelAndView.addObject("name", "huanhuan");
    return modelAndView;
}

From source file:com.naver.timetable.controller.UserController.java

@RequestMapping(value = "/editUser")
public ModelAndView editUser(HttpServletRequest request, String email) {
    ModelAndView mv = new ModelAndView("userEditForm");
    mv.addObject("user", userBO.getUser(email));

    // ? ?   ? ./*from   ww w . jav a 2s.  co m*/
    HttpSession session = request.getSession();
    session.setAttribute("targetPage", request.getHeader("Referer"));
    return mv;
}

From source file:com.pet.demo.web.VisitController.java

@RequestMapping(value = "/owners/*/pets/{petId}/visits", method = RequestMethod.GET)
public ModelAndView showVisits(@PathVariable int petId) {
    ModelAndView mav = new ModelAndView("visitList");
    mav.addObject("visits", this.petdemoService.findPetById(petId).getVisits());
    return mav;/*from   w w w.  j  ava2s . co  m*/
}

From source file:com.ut.healthelink.controller.solutionsController.java

/**
 * The '/services' request will display the professional services page.
 *//*ww w.  j  a  v a2 s.c o m*/
@RequestMapping(value = "/services", method = RequestMethod.GET)
public ModelAndView services() throws Exception {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("/services");
    mav.addObject("pageTitle", "Professional Services");
    return mav;
}

From source file:com.vmg.controller.ProductController.java

@RequestMapping(value = "/saveProductDetails", method = RequestMethod.GET)
public ModelAndView saveProductDetails(@RequestParam("productsList") String productsList) {

    List<Product> productList = new ArrayList<>();

    ObjectMapper objectMapper = new ObjectMapper();

    try {//  w  w  w.  j  a  v a 2  s  . co m
        JSONArray jsonArray = new JSONArray(productsList);
        for (int i = 0; i < jsonArray.length(); i++) {
            JSONObject jsonObject = (JSONObject) jsonArray.get(i);
            Product product = objectMapper.readValue(jsonObject.toString(), Product.class);
            productList.add(product);
        }

        if (!productList.isEmpty()) {
            productService.saveProductList(productList);
        }
    } catch (JSONException | IOException ex) {
        Logger.getLogger(ProductController.class.getName()).log(Level.SEVERE, null, ex);
    }
    ModelAndView modelAndView = new ModelAndView("success");
    modelAndView.addObject("response", "Your data has been saved successfully");
    return modelAndView;
}

From source file:org.fon.documentmanagementsystem.controllers.TipdokumentaController.java

@RequestMapping(path = "/details/{id}", method = RequestMethod.GET)
public ModelAndView showDocumentType(@PathVariable("id") long id) {
    Tipdokumenta tipdokumenta = tipDokumentaService.findOne(id);
    ModelAndView mv = new ModelAndView("documenttype_add");
    mv.addObject("documenttype", tipdokumenta);
    return mv;//from ww w  .  j a  v  a  2 s  .c  om
}

From source file:org.jessezhu.starriver.controller.ProfileController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView updateForm() throws Exception {
    Long id = getCurrentUserId();
    ModelAndView result = new ModelAndView("account/profile");
    result.addObject("user", accountService.selectByKey(id));
    return result;
}

From source file:se.inera.certificate.web.controller.PageController.java

public void populateUseMinifiedJavaScript(ModelAndView model) {
    model.addObject("useMinifiedJavaScript",
            environment.getProperty("minaintyg.useMinifiedJavaScript", "true"));
}

From source file:com.castlemock.web.basis.web.mvc.controller.user.DeleteUserController.java

/**
 * The method retrieves a user from the database and creates a view to display the
 * retrieved user.//w  w w. ja va  2 s.  co  m
 * @param userId The id of the user that should be retrieved
 * @return A view that displays the user
 */
@PreAuthorize("hasAuthority('ADMIN')")
@RequestMapping(value = "/{userId}/delete", method = RequestMethod.GET)
public ModelAndView defaultPage(@PathVariable final String userId) {
    final ReadUserOutput readUserOutput = serviceProcessor.process(new ReadUserInput(userId));
    final UserDto userDto = readUserOutput.getUser();
    final ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(USER, userDto);
    return model;
}