java - Spring mvc annotation, can't find jsp page -
mvc-dispatcher-servlet.xml :
<context:component-scan base-package="com.springapp.mvc" /> <mvc:annotation-driven /> <bean name="viewresolver"class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/pages/"/> <property name="suffix" value=".jsp"/> </bean>
after adding in file, jetty throws error: *.jsp not found. if remove annotation-driven here, works fine. basic servelet.
controller code :
@requestmapping(value = "/v1/deliveryeta", method = requestmethod.get) public string getdeliveryeta(model model) { model.addattribute("deliveryeta",new deliveryeta()); return "getdeliveryeta"; }
and getdeliveryeta.jsp :
<%@ taglib prefix="th" uri="http://www.springframework.org/tags/form" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <html> <body> <form:form method="post" action="/v1/deliveryeta" commandname="deliveryeta"> <table> <tr> <td>origin address: <font color="red"><form:errors path="originaddress" /></font></td> </tr> <tr> <td><form:input type="text" path="originaddress" /></td> </tr> <tr> <td>destination address: <font color="red"><form:errors path="destinationaddress" /></font></td> </tr> <tr> <td><form:input type="text" path="destinationaddress" /></td> </tr> <tr> <td><input type="submit" value="submit" /></td> </tr> </table> </form:form> </body> </html>
i think view resolver property values should defined this:
<property name="prefix"> <value>/web-inf/pages/</value> </property> <property name="suffix"> <value>.jsp</value> </property>
Comments
Post a Comment