我觉得它必须是某种配置的东西,因为正如我所说的,我可以访问嵌入的Java所包含的页面,但是当我试图从JSP中引用的调用和servlet引用(http://localhost:8081/luv2code/jspdemo/step5/servletdemo)您可以看到它在我的web中声明。xml is giving me a 404.
我已经有了这个应用程序,我正在学习一些教程,当我从我的IDE执行它时,它工作得很好,但是我试图在webapps目录中创建一个爆炸式的战争,它正在做一些意想不到的事情。我使用内嵌Java代码的所有页面看起来都很好,但是我有这行HTML
Lets have some fun: <%= com.luv2code.Step1.FunUtils.makeItLower("FUN FUN FUN")%><br/>
而且它似乎破坏了我的部署
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: [254] in the jsp file:
[/jspdemo/Step1/FirstLesson.jsp]
com.luv2code.Step1.FunUtils cannot be resolved to a type
251: </span>
252: </p>
253: <p>2. Call the java class<br/>
254: Lets have some fun: <%=
com.luv2code.Step1.FunUtils.makeItLower("FUN FUN FUN")%><br/>
255: Lets have some fun: <%=
com.luv2code.Step1.FunUtils.makeItLower("FUN FUN FUN")%><br/>
256: </p>
257: <p>
这是我的目录结构

部署webapps文件夹时如下所示
所以,我可以http://localhost:8081/luv2code/jspdemo/index.jsp很好,但是当我试图访问类中的文件时,似乎遇到了错误。我是否需要在web.xml中放入一些东西,以便它知道如何访问这些类?我觉得web.xml是关键,但我只是不确定,而且我太缺乏经验了,当我试图研究它时,我会不知所措。我的web.xml是非常基本的,但是我在其中放了如下内容。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>HelloWorld Application</display-name>
<description>
This is a simple web application with a source code organization
based on the recommendations of the Application Developer's Guide.
</description>
<servlet>
<servlet-name>ServletDemo</servlet-name>
<servlet-class>com.luv2code.Step5.ServletDemo</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletDemo</servlet-name>
<url-pattern>/Step5/ServletDemo</url-pattern>
</servlet-mapping>
</web-app>
我觉得它必须是某种配置的东西,因为正如我所说的,我可以访问嵌入的Java自带的页面,但是当我尝试从JSP和servlet引用中引用的调用访问自己编译的类时,我会得到这个错误。http://localhost:8081/luv2code/jspdemo/Step5/ServletDemo)在my web.xml中声明的是404。