Need to convert the UI pages in .html to .vm(velocity template) files using spring mvc.I tried searching on other sites but did not got any nice information.
Any useful site/help will be appreciated. Thanks
Need to convert the UI pages in .html to .vm(velocity template) files using spring mvc.I tried searching on other sites but did not got any nice information.
Any useful site/help will be appreciated. Thanks
This html to .vm conversion thing in your question seems a bit misleading as whatever it may be- .vm(velocity template), .jsp , .ftl(freemarker template) ,etc , When rendered on the front end it is just html.
I believe, you want to know how can you configure spring mvc to use velocity as your view layer.
For this, you need to configure your view resolver as VelocityViewResolver.
Go to your 'mvc-dispatcher-servlet.xml' or '-servlet.xml' which by default contains spring's InternalResourceViewResolver configuraion used for jsp files. You need to add velocity specific configuration like this:
<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="cache" value="true"/>
<property name="prefix" value=""/>
<property name="suffix" value=".vm"/>
</bean>
This link might be of good help.
First of all, you need to be clear that when you are using MVC, you can serve the pages in any way you want. Here is one possible solution to your problem which is the actual code from my own application.
You might want to serve the *.html requests like this.
web.xml
Then in your servlet-context.xml, you can configure the
VelocityViewResolver
like this.Then from your controller, return the name of the view you want to render, this should not include the extension.
This would solve your problem.
Please be clear that in MVC, the view is returned based on the type of your request, no actual conversion of file-types takes place.