Why ModelMap, Model, @ModelAttribute, ModelAndView required when a simple return of jsp page name in string can do the work

shweta :

I have the following spring mvc code snippet that works fine:

Controller snippet:

@RequestMapping(value="/submitForm", method=RequestMethod.POST)
public String formSubmission(Employee employee)
{
    return "EmployeeWelcome";
}

On form data printing page:

<html>
<h4>List of Request Parameters</h4>
<h4>first name - ${employee.firstName}</h4>
<h4>last name - ${employee.lastName}</h4>
<h4>user email - ${employee.email}</h4>
<h4>user salary - ${employee.salary}</h4> 
</html>

The above prints all the values successfully, then why is the following required?

ModelMap, Model, @ModelAttribute, ModelAndView
Trishala :

If you want to get the model value or any message to the Ui from the java side then you would need these

You can check the details here: What are the differences between Model, ModelMap, and ModelAndView?

Check the docs: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/ModelAndView.html

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Return simple text String with ModelAndView

ModelMap/ModelAndView data is not displayed

How do I access ModelMap in a jsp?

How to access a ModelAndView object added without attribute name within the jsp page

How can I return Id when model state cannot be work?

Why can't I return a figure when scraping html page?

Why it is required to return *this when this is still being passed?

Why does my page page return blank when using a server name with mod_rewrite?

What's the difference between ModelAndView and ModelMap?

Should the name of a @ModelAttribute be the same as the model in a session

When to use ModelAndView vs Model in Spring?

Why do I get a warning when return a pointer to a string?

Why an immutable reference can work in match when mutable reference is required by function in Rust?

Why do I get an error when running a method from a jsp page, but not from a main method?

Why do PostgreSQL functions return null columns instead of no rows when the return type is a table name?

Why doesn't Beautifulsoup return the required items from this page?

modelAttribute in jsp page returning null on non input fields

Why simple exit program do not work?

What is the difference between return ModelAndView and return String in Spring MVC?

Spring: JSP not reading passed ModelMap?

ModelAndView reference to view with name model is null in spring boot

In Javascript, why do return; when return nothing?

Why the event does not work when clicking on an element? (simple to-do list project)

Simple String Comparison In Javascript Do Not Work

Why is this view-model string field treated as required?

Why do I see extra text at the top of my view page when using the @Model statement?

why my code doesn't work when I am trying to concatenate a function's return value with a string?

ModelAttribute in .jsp file: Can not resolve symbol. Spring

Why do variable in an inner function return nan when there is the same variable name at the inner function declared after log