• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Web Page created using spring mvc

 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic