XML では簡単に構成できますが、@Configuration では構成できません。
プロパティ
spring.view.class=org.springframework.web.servlet.view.JstlView
spring.view.prefix=/WEB-INF/jsp/
spring.view.suffix=.jsp
コード
@Bean
public UrlBasedViewResolver viewResolver() throws ClassNotFoundException {
//ViewResolver Setting
Class viewResolverClass = env.getPropertyAsClass("spring.view.class", Class.class);
String viewResolverPrefix = env.getProperty("spring.view.prefix");
String viewResolverSuffix = env.getProperty("spring.view.suffix");
UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
viewResolver.setViewClass(viewResolverClass);
viewResolver.setPrefix(viewResolverPrefix);
viewResolver.setSuffix(viewResolverSuffix);
return viewResolver;
}
エラー
throws java.lang.ClassNotFoundException] threw exception; nested exception is java.lang.IllegalArgumentException: Cannot convert value [org.springframework.web.servlet.view.JstlView] from source type [String] to target type [Class]
前もって感謝します。