问题
I'm trying to create a servlet which loads "FirstJSP.jsp" in WEB-INF/jsp/FirstJSP.jsp
I'm having a problem with my web.xml file. I've looked through dozens of forum posts both on SO and elsewhere, yet none of them work.
Here's my current revision
<?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/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<servlet>
<servlet-name>Queue</servlet-name>
<jsp-file>/jsp/FirstJSP.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>Queue</servlet-name>
<url-pattern>/FirstJSP.jsp</url-pattern>
</servlet-mapping>
And here is a screenshot to show the file hierarchy. I think I've tried about every method possible, so there must be something very simple I am missing :) Thank you.
回答1:
I guess JSPs should be outside the WEB-INF. You may see an example here http://code.google.com/appengine/docs/java/gettingstarted/creating.html
or even better, here: http://download.oracle.com/javaee/5/tutorial/doc/gexap.html
回答2:
Your css and jsp folders should be out of WEB-INF directory as this directory will be locked (when you want direct access to your jsp files, which I think you want) and you don't need to map JSP files :)
You should remove <servlet> and <servlet-mapping> from your web.xml
来源:https://stackoverflow.com/questions/6642745/web-xml-ignoring-main-jsp-file