我正在尝试使用 Spring 3 和注释来完成本教程http://www.mkyong.com/spring-mvc/spring-mvc-export-data-to-excel-file-via-abstractjexcelview/ 。
所以我有一个 WebAppConfig 类
@Configuration
@ComponentScan("com.mkyong.common")
@EnableWebMvc
public class WebAppConfig {
@Bean
public InternalResourceViewResolver setupViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/pages/");
resolver.setSuffix(".jsp");
return resolver;
}
}
和一个 WebAppInitializer 类
class public class WebAppInitializer implements WebApplicationInitializer {
public void onStartup(ServletContext servletContext) throws ServletException {
XmlWebApplicationContext appContext = new XmlWebApplicationContext();
String[] locations = { "classpath*:applicationContext.xml" };
appContext.setConfigLocations(locations);
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(appContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
servletContext.addListener(new ContextLoaderListener(appContext));
servletContext.getServletRegistration ("default").addMapping ("*.js", "*.css", "*.jpg", "*.gif", "*.png");
}
}
我对经典页面(没有 excel)没有任何问题,但是使用 excel,应用程序会查找 ExcelRevenueSummary.jsp。
有人知道我怎么能“翻译”这个:
<bean id="ExcelRevenueSummary"
class="com.mkyong.common.view.ExcelRevenueReportView">
</bean>
以 Spring 3 使用的正确格式?
谢谢你。