java - How can I map my Spring URL to a JSP file in /WEB-INF/views? -


i'm having trouble doing spring (using 3.0.5.release) mapping. want map url http://mydomain/context-path/user/registrationform.jsp jsp page at

/web-inf/views/user/registrationform.jsp 

but i'm getting 404. have controller setup …

@controller @requestmapping("registrationform.jsp") public class registrationcontroller {      private static logger log = logger.getlogger(registrationcontroller.class);     …     public void setregistrationvalidation(         registrationvalidation registrationvalidation) {         this.registrationvalidation = registrationvalidation;     }      // display form on request     @requestmapping(method = requestmethod.get)     public string showregistration(map model) {         final registration registration = new registration();         model.put("registration", registration);         return "user/registrationform";     } 

here dispatcher-servlet.xml …

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemalocation="http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

<!-- enable annotation driven controllers, validation etc... --> <mvc:annotation-driven />  <context:component-scan base-package="com.burrobuie.eventmaven" />  <bean id="viewresolver"     class="org.springframework.web.servlet.view.internalresourceviewresolver">     <property name="prefix">         <value>/web-inf/views/</value>     </property>     <property name="suffix">         <value>.jsp</value>     </property> </bean>  <bean id="messagesource"     class="org.springframework.context.support.reloadableresourcebundlemessagesource">     <property name="basename" value="/messages" /> </bean>  </beans> 

and here web.xml …

<servlet>     <servlet-name>dispatcher</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <load-on-startup>1</load-on-startup> </servlet>  <servlet-mapping>     <servlet-name>dispatcher</servlet-name>     <url-pattern>/</url-pattern> </servlet-mapping>  

what else need configure (or configure differently) make mapping work? harder - dave

@controller @requestmapping("registrationform.jsp") public class registrationcontroller { 

the requestmapping annotation @ class level should use common url pattern "item/*" , links contains "/item" followed other pattern mapped controller. "user/" in case requestmapping annotation @ method level used mapping sub url "item/add" or "item/delete", "registrationform.jsp' in case try this:

@controller @requestmapping("/user") public class registrationcontroller {      private static logger log = logger.getlogger(registrationcontroller.class);     …     public void setregistrationvalidation(         registrationvalidation registrationvalidation) {         this.registrationvalidation = registrationvalidation;     }      // display form on request     @requestmapping(value="/registrationform.jsp",method = requestmethod.get)     public string showregistration(map model) {         final registration registration = new registration();         model.put("registration", registration);         return "user/registrationform";     } 

this map /user/registrationform.jsp


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -