简体   繁体   English

web.xml 忽略主要 JSP 文件

[英]web.xml ignoring main JSP file

I'm trying to create a servlet which loads "FirstJSP.jsp" in WEB-INF/jsp/FirstJSP.jsp我正在尝试创建一个在 WEB-INF/jsp/FirstJSP.jsp 中加载“FirstJSP.jsp”的 servlet

I'm having a problem with my web.xml file.我的 web.xml 文件有问题。 I've looked through dozens of forum posts both on SO and elsewhere, yet none of them work.我已经浏览了 SO 和其他地方的数十个论坛帖子,但没有一个有效。

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.我想我已经尝试了所有可能的方法,所以一定有一些非常简单的东西我错过了:) 谢谢。

截屏

I guess JSPs should be outside the WEB-INF.我猜 JSP 应该在 WEB-INF 之外。 You may see an example here http://code.google.com/appengine/docs/java/gettingstarted/creating.html您可能会在这里看到一个示例http://code.google.com/appengine/docs/java/gettingstarted/creating.html

or even better, here: http://download.oracle.com/javaee/5/tutorial/doc/gexap.html甚至更好,在这里: http://download.oracle.com/javaee/5/tutorial/doc/gexap.html

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:) 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您应该从 web.xml 中删除<servlet><servlet-mapping>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM