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:org.jessezhu.starriver.controller.LoginController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView fail(@RequestParam(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM) String username) {
    ModelAndView result = new ModelAndView("account/login");
    result.addObject(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM, username);
    return result;
}

From source file:org.zlogic.vogon.web.controller.JspController.java

/**
 * Returns the fragment ("/fragments") path
 *
 * @param fragment the fragment name/*from w w w  .  j a  v a 2s . com*/
 * @return the fragment ("/fragments") path
 */
@RequestMapping(value = { "/fragments/{fragment}.fragment" })
public ModelAndView fragmentModelAndView(@PathVariable String fragment) {
    String target = MessageFormat.format("fragments/{0}", new Object[] { fragment }); //NOI18N
    ModelAndView model = new ModelAndView(target);
    model.addObject("configuration", configuration); //NOI18N
    return model;
}

From source file:br.com.joaops.smt.controller.LoginController.java

@RequestMapping(value = "/login/error", method = RequestMethod.GET)
public ModelAndView loginError(Locale locale, HttpServletRequest request, HttpServletResponse response) {
    ModelAndView mav = new ModelAndView("login/index");
    mav.addObject("error", "error");
    return mav;/*from  ww w. j ava 2  s  .c  o m*/
}

From source file:br.com.joaops.smt.controller.LoginController.java

@RequestMapping(value = "/logout", method = RequestMethod.GET)
public ModelAndView logout() {
    ModelAndView mav = new ModelAndView("login/index");
    mav.addObject("logout", "logout");
    return mav;//w w  w.  j  a v  a  2s  .  c  o m
}

From source file:com.griddynamics.banshun.web.AnnotatedTestController.java

@RequestMapping("/annotation-test.html")
public ModelAndView annotationTest() {
    String message = "Hello Spring MVC";

    ModelAndView modelAndView = new ModelAndView("testView");
    modelAndView.addObject("message", message);

    return modelAndView;
}

From source file:com.griddynamics.banshun.web.AnnotatedTestController.java

@RequestMapping("/another-annotation-test.html")
public ModelAndView anotherAnnotationTest() {
    String message = "Hello Another Spring MVC";

    ModelAndView modelAndView = new ModelAndView("testView");
    modelAndView.addObject("message", message);

    return modelAndView;
}

From source file:comsat.sample.jpa.web.IndexController.java

@RequestMapping("/")
@Transactional(readOnly = true)// www  . j  av a2 s  . com
public ModelAndView index() throws InterruptedException, SuspendExecution {
    Fiber.sleep(10);
    List<Note> notes = this.noteRepository.findAll();
    ModelAndView modelAndView = new ModelAndView("index");
    modelAndView.addObject("notes", notes);
    return modelAndView;
}

From source file:by.bsuir.finance.controllers.SalaryController.java

@RequestMapping(value = "/viewall")
public ModelAndView viewall() {
    ModelAndView model = new ModelAndView("salary/viewall");
    model.addObject("salaries", salaryService.findAll());
    return model;
}

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

@RequestMapping(value = Constants.PREFERENCES_URI, method = RequestMethod.POST)
public ModelAndView submitForm(@ModelAttribute PreferenceSettings preferences) {
    log.debug("In submitForm method...");
    preferencesManager.savePreferenceSettings(preferences);
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject(PREFERENCES_WAS_SAVED_NAME, true);
    modelAndView.setViewName("preferences");
    return modelAndView;
}

From source file:controller.ExerciseController.java

@RequestMapping(value = "/Exercises/", method = RequestMethod.GET)
public ModelAndView listExercises() {

    List<Exercise> listExercises = template.listExercises();

    ModelAndView model = new ModelAndView("exercise/Exercises");

    model.addObject("listExercises", listExercises);

    return model;
}