0
votes

I wanted to use html page instead of using jsp page. But while using html page I am getting error. But if I use jsp page i don't get any error.

When I use <property name="suffix" value=".jsp"/>I don't get any error. Here my spring-servlet.xml file

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

<mvc:annotation-driven/>
<context:component-scan base-package="org.avijit"/>
<bean id="jspViewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/"/>
    <property name="suffix" value=".html"/>
</bean>

My Controller class is

 package org.avijit;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;

    @Controller
    public class BaseController {
        @RequestMapping(value="/", method = RequestMethod.GET)
        public String homePage()
        {
            return "welcomePage";
        }
    }
1
What is the content of welcomePage.html?xingbin

1 Answers

1
votes

At last i got an answer. I have changed my viewresolver class to

<bean
        id="templateResolver"
        class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver"
        p:prefix="/WEB-INF/views/"
        p:suffix=".html"
        p:templateMode="HTML5"

></bean>

<bean id="templateEngine"
      class="org.thymeleaf.spring4.SpringTemplateEngine">
    <property name="templateResolver" ref="templateResolver" />
</bean>

<bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
    <property name="templateEngine" ref="templateEngine" />
</bean>

Now everything working fine ! :)