I am using JSF in one of my application and the scenario is as follows:
1.I have a pages
folder under WEB_INF
2.Inside pages
I have a.jsp
3.When I deploy this application with the local tomcat it says "The requested resource (/pages/a.jsp) is not available."
<?xml version="1.0" encoding=开发者_如何学编程"UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Sample_Proj</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>AddUser.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
Is there anything else i need to add into web.xml? The below url is what I'm using to hit the page: http://localhost:8080/Sample_Proj/WEB-INF/page/AddUser.jsp
Your jsp files / folders should exist in the root of the web project and not in the WEB-INF folder, i.e.:
/pages/a.jsp
/WEB-INF/...
Your web.xml file is very much incomplete when it comes to a JSF web project. I would recommend reading the Java EE 6 tutorial, you can read through this chapter on getting started with web applications
精彩评论