0

I am using spring web mvc for registering an user. But my User class has a variable of type Website.

public class User{

private String email;

private WebSite website;

}

public class WebSite{

private String webSiteUrl;

}

In my registration form i need 2 text boxes for email and for webSiteUrl.

For email i am using the below way:

<label for="email">Email:</label> <form:errors path="email" cssClass="errors"/> 
<form:input path="email" required="true" placeholder="[email protected]" type="email"/>

How should i map webSiteUrl in jsp and its errors? I tried google but not able to find working solutions, can someone please help me.

Thanks,

Ramesh.V

1 Answer 1

1

You may try

<label for="website.webSiteUrl">Website:</label>
<form:errors path="website.webSiteUrl" cssClass="errors"/>
<form:input path="website.webSiteUrl"/>

Haven't tested, but should work..

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry @arun it doesn't work, throws an error org.springframework.beans.NotReadablePropertyException: Invalid property 'webSite' of bean class [com.richwp.richsalesagent.model.User]: Bean property 'webSite' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
@user988150: Sorry if I sound stupid, but can you please try "website"(with a small "s") in your jsp? I am saying this because your User class, the one you posted above, has a website with a small "s" and error message says "webSite" with a caps S

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.