This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Spring and the fly likes Web Page created using spring mvc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Web Page created using spring mvc" Watch "Web Page created using spring mvc" New topic
Author

Web Page created using spring mvc

Anand Sivathanu
Ranch Hand

Joined: Jun 25, 2010
Posts: 76
Hi Friends,
I have created a web using spring mvc.

I have a field in web page called

Favourite Web Frameworks: checkbox struts checkbox springmvc checkbox hibernate

My requirement is
label will be "Struts"
value is "struts"

label will be "Spring MVC"
value is "springmvc"

Trial 1 - starts
I have create a class called
"Framework.java"

In UserRegistrationFormController.java,

In UserRegistration.jsp,

Now when i try to submit the form,form is not submitted and "invalid data" is thrown.
Trial 1 - ends

Trial 2 - starts
So I tried the other way,instead of using "Framework" class,I used "String" class.

In UserRegistration.jsp,

Here web page displayed checkboxes for springmvc,struts1,struts2,jsf,apachewicket.
here both label and value of check box are same.when form is submitted it is working.
But here we cannot achieve, label displayed in web page to be different with actual value

As label should be more readable and value of a label will not be same
for eg:-
Label is "Spring MVC" (displayed to user)
value is "springmvc" (actual value for processing).
I used Trial 1 (mentioned above).But "invalid data" in red font is coming.

I googled for the issue.Cannot able to find the suggesstions.

Please guide me in this issue.

Regards,
Anand
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1646
    
    7

My first suggestion to you if you are learning Spring is going to be use the modern controllers. Your controllers should not need to implement any Spring interfaces or extend any Spring classes (like SimpleFormController etc). I would first recommend you to update your Spring to the latest version and rework your projects controllers with the modern @Controller style.

You can see some examples of this here:

http://krams915.blogspot.com/2010/12/spring-3-mvc-using-modelattribute-in.html
https://github.com/SpringSource/spring-mvc-showcase

[How To Ask Questions][Read before you PM me]
Anand Sivathanu
Ranch Hand

Joined: Jun 25, 2010
Posts: 76
Bill Gorder wrote:My first suggestion to you if you are learning Spring is going to be use the modern controllers. Your controllers should not need to implement any Spring interfaces or extend any Spring classes (like SimpleFormController etc). I would first recommend you to update your Spring to the latest version and rework your projects controllers with the modern @Controller style.

You can see some examples of this here:

http://krams915.blogspot.com/2010/12/spring-3-mvc-using-modelattribute-in.html
https://github.com/SpringSource/spring-mvc-showcase


Hi Bill Gorder,

Thanks for the suggestion. URL that you have mentioned looks good. will practice with this also and get a good idea about spring mvc

Now I am following @Controller

I able to solve the above issue by using map,instead of using list."key" will be the actual value of the label and label will be the present as value against the key.

eg:-
map.put("spring3","Spring Framework")

"Spring Framework" will label displayed in JSP page and "spring3" is the actual value of the label "Spring Framework"

Regards,
Anand

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Page created using spring mvc
 
Similar Threads
Can't display validation error message
problem while loading the welcome page
IllegalStateException:Neither BindingResult nor plain target object for bean name available
can't find css, images and js static files
Returning List Object but not able to display value using Spring c:foreach tag