VOLVO
VOLVO

Reputation: 561

How do I add new jsp page in Spring MVC netbeans Project?

I have a simple JSP spring project in net-beans.

I want to create a new page and go to it from "index.jsp(html)".

<form id="form1" method="post" action="newpage.jsp">
   ...
   button with submit type
</form>

What do I for go to newpage.jsp?

I add the newpage.jsp and run my project but Server can not find this page!!!

Is any setting to run correct project? What is this?

my project:

enter image description here

index page:

enter image description here

enter image description here

other page:

enter image description here

enter image description here

Upvotes: 2

Views: 3344

Answers (1)

user2575725
user2575725

Reputation:

Problem is the form target is at wrong location:

<form id="form1" method="post" action="newpage.jsp">

You see at the address bar before submit its:

Test/index.html

After submit its:

Test/newpage.jsp

Whereas, the jsp location is under WEB-INF/jsp/newpage.jsp.

In general you should submit form to controller, use the InternalResourceViewResolver to point out the pages under WEB-INF in your dispatcher-servlet.xml.

<bean id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"
      p:prefix="/WEB-INF/jsp/"
      p:suffix=".jsp" />

You can also go through this tutorial

Upvotes: 4

Related Questions