Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9152793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:08:29+00:00 2026-06-17T12:08:29+00:00

In spring when control return to view i have seen it return through, return

  • 0

In spring when control return to view i have seen it return through,

return new ModelAndView("contact", "command", new Contact());

But i have seen a example where just a string name returns as below,

 @RequestMapping("/index")
    public String listContacts(Map<String, Object> map) {

        map.put("contact", new Contact());
        map.put("contactList", contactService.listContact());

        return "contact";
    }

Is this also valid or a good practice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:08:30+00:00Added an answer on June 17, 2026 at 12:08 pm

    Yes it is valid to return a String. It will be interpreted as the View name (ref):

    A String value which is interpreted as view name, with the model implicitly determined through command objects and ModelAttribute annotated reference data accessor methods.

    Is it a good practice ?

    Let’s say that’s a matter of taste. (My point of view is that this style requires more knowledge about implicit behavior of Spring MVC and so I don’t like it because it make the code more difficult to understand for someone not aware of all this implicit behavior, but it’s really just personal preference…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a partial view... <%@ Control Language=C# Inherits=System.Web.Mvc.ViewUserControl<NewsletterUnsubscribe_MVC3v2.Models.IntegraRecord> %> <% if (!String.IsNullOrEmpty(Model.ErrorMessage))
I have tried to understand AOP, Dependency Injection and Inversion of Control SPRING related
Spring MVC uses a DispatcherServlet to route control to an appropriate Controller. But where
I am binding string array to the Repeater Control, string[] strPageSize = new string[25];
I'm making a user control, and I manually draw the text string, but I
void Foo() { string ID = test; var testctrl = new Control() {ID =
I have a partial view with a DropDownList control and a textbox. When nothing
I have a user control I have created that contains a details-view that I
My LogIn action originally looked like this: return new RedirectResult(nameValueCollection[ReturnUrl]); But, I would like
I just got stuck. I have 2 view controllers one is WatchListViewController and 2nd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.