I have developed an java web application using maven and spring mvc 4 in eclipse. I am using spring annotation without web.xml and using jboss 7.1 application server.
I am using WebApplicationInitializer as i am not using web.xml
public void onStartup(ServletContext servletContext)
throws ServletException {
AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext();
webApplicationContext.register(Config.class);
webApplicationContext.setServletContext(servletContext);
Dynamic dispatcherServlet = servletContext.addServlet("dispatcher",
new DispatcherServlet(webApplicationContext));
dispatcherServlet.addMapping("/*");
dispatcherServlet.setLoadOnStartup(1);
My configuration code is shared below,
The jsp page is not rendered
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
super.configureDefaultServletHandling(configurer);
};
@Bean
public InternalResourceViewResolver getViewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
viewResolver.setViewClass(JstlView.class);
return viewResolver;
}
The output of the jsp page in the browser for the request is
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Home Page</title>
</head>
<body>
</body>
</html>