문제

I was using Spring 3.1x and below is the code how I used to set freemarker properties in my config class

@Configuration
public class MvcConfig {

@Bean
public FreeMarkerConfigurer freeMarkerConfigurer() {
    FreeMarkerConfigurer fmc = new FreeMarkerConfigurer();
    FreeMarkerConfigurer
    fmc.setTemplateLoaderPath("/WEB-INF/views/");
    return fmc;
}

@Bean(name = DispatcherServlet.MULTIPART_RESOLVER_BEAN_NAME)
public MultipartResolver multipartResolver() {
    return new CommonsMultipartResolver();
}

@Bean
public FreeMarkerViewResolver freeMarkerViewResolver() {
    FreeMarkerViewResolver fvr = new FreeMarkerViewResolver();
    fvr.setCache(false);
    fvr.setPrefix("");
    fvr.setSuffix(".ftl");
    fvr.setRequestContextAttribute("rc");
    return fvr;
}

}

Now I upgrade my spring to 3.2.3 release and it's telling

The method setTemplateLoaderPath(String) is undefined for the type MvcConfig

How to set freemarker view path in spring 3.2.3 using java config?

도움이 되었습니까?

해결책

There's an extra "FreeMarkerConfigurer" line in your code above (unless that's just a copy/paste error). Can you post the full error message?

You may also need to add the spring-context-support JAR to your project. Here's the Maven pom.xml entry:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>3.2.3.RELEASE</version>
</dependency>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top