Reputation: 561
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:
index page:
other page:
Upvotes: 2
Views: 3344
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