henk
Oct 6th, 2005, 04:31 AM
Hi,
I am trying to use jsp and freemarker together. The freemarker part works, but the jsp part does not because freemarker tries to find the corresponding template.
Configuration :
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewR esolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.InternalResou rceView
</value>
</property>
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<!-- freemarker config -->
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.Fr eeMarkerConfigurer">
<property name="templateLoaderPath"
value="/WEB-INF/freemarker/" />
</bean>
<bean id="freemarkerViewResolver"
class="org.springframework.web.servlet.view.freemarker.Fr eeMarkerViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".ftl" />
</bean>
I thought that by putting the jsp part first, if spring finds a jsp file with the right name, it would output the jsp. If het jsp file does not exist, then it will look for the freemarker template. Clearly this is not happening. Also the order property (mentioned in the docs) is not available.
Is there a way to solve this problem or should I just choose one of the two views ?
My second question is about how an url is mapped to a controller.
I would like to achieve that an url like :
http://localhost:8080/webapp/admin/ is mapped to a method named 'overview'. and an url like http://localhost:8080/webapp/admin/listall is mapped to a method named 'listall'.
I have a SimpleURLMapping with a property <prop key="/admin/">paramMultiController</prop>
The paramMultiController has a PropertiesMethodNameResolver configured like this :
<prop key="/listall">listAllProducts</prop>
<prop key="/*">overview</prop>
But this does not work. When browsing to http://localhost:8080/webapp/admin/anything, it says not found. While I thought a '*' as a property would bring me to the 'overview' method.
Any ideas ?
thanks a lot
Henk
I am trying to use jsp and freemarker together. The freemarker part works, but the jsp part does not because freemarker tries to find the corresponding template.
Configuration :
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewR esolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.InternalResou rceView
</value>
</property>
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<!-- freemarker config -->
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.Fr eeMarkerConfigurer">
<property name="templateLoaderPath"
value="/WEB-INF/freemarker/" />
</bean>
<bean id="freemarkerViewResolver"
class="org.springframework.web.servlet.view.freemarker.Fr eeMarkerViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".ftl" />
</bean>
I thought that by putting the jsp part first, if spring finds a jsp file with the right name, it would output the jsp. If het jsp file does not exist, then it will look for the freemarker template. Clearly this is not happening. Also the order property (mentioned in the docs) is not available.
Is there a way to solve this problem or should I just choose one of the two views ?
My second question is about how an url is mapped to a controller.
I would like to achieve that an url like :
http://localhost:8080/webapp/admin/ is mapped to a method named 'overview'. and an url like http://localhost:8080/webapp/admin/listall is mapped to a method named 'listall'.
I have a SimpleURLMapping with a property <prop key="/admin/">paramMultiController</prop>
The paramMultiController has a PropertiesMethodNameResolver configured like this :
<prop key="/listall">listAllProducts</prop>
<prop key="/*">overview</prop>
But this does not work. When browsing to http://localhost:8080/webapp/admin/anything, it says not found. While I thought a '*' as a property would bring me to the 'overview' method.
Any ideas ?
thanks a lot
Henk