0

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? Commented May 6, 2018 at 9:02

1 Answer 1

1

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 ! :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.