I'm using Spring, in that I have user.jsp
user.jsp
has three separate divisons: 1. Personal, 2. Educational, 3. Awards. Each section has different forms .jsp that I have created.
Now I'm thinking to include these three forms into user.jsp
and display Model using one Controller.
Here is my controller class code:
@Controller
@RequestMapping(value="profile")
public class UserProfileController {
@RequestMapping(value="user", method=RequestMethod.GET)
public String user(Model model) throws Exception {
model.addAttribute("profile", new PersonalForm());
return "profile/user";
}
And this is my Personal.jsp file (all remaining files are the same but names are different)
So how to include these three jsp into user.jsp
? Actually I'm trying but Eclipse is showing an error. Below is my error code in user.jsp
:
Fragment "profile/professional.jsp" was not found at expected path /EClass/WebContent/WEB-INF/ pages/profile/profile/professional.jsp
So please help me how to include and how to work with single controller?
In your User.jsp write following code...
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<fieldset id="profile_proffiesional">
<form:form action="profile/user" modelAttribute="profile">
<jsp:include page="personal.jsp"></jsp:include>
<jsp:include page="educational.jsp"></jsp:include>
<jsp:include page="awards.jsp"></jsp:include>
</form:form>
</fieldset>