I have the following folder structure for my Maven WebApp Project
src
+-----main
+-----java
| +-----com
| +------controller
| +-----HomeController.java
|
+-----resources
+-----webapp
+-----resources
| +-----css
| +-----home.css
+-----WEB-INF
+-----jsp
| +------home.jsp
+-----eLibrary-servlet.xml
+-----web.xml
web.xml:
<servlet>
<servlet-name>eLibrary</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>eLibrary</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<display-name>eLibrary</display-name>
eLibrary-servlet.xml:
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEF-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<mvc:resources location="/resources/" mapping="/resources/**" />
HomeController.java:
@Controller
public class HomeController {
@RequestMapping("/")
public String getHomePage() {
return "home";
}
}
And in my home.jsp, I'm trying to access the CSS file using ${pageContext.request.contextPath}/resources/css/home.css
But neither my JSP file(i.e. home.jsp) nor the CSS file(i.e. home.css) is loading in browser and I'm getting HTTP Status 404 when accssing http://localhost:8080/eLibrary/ with a message
/eLibrary/WEF-INF/jsp/home.jsp
and description
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.