收到警告“[org.springframework.web.servlet.PageNotFound](默认任务-1)没有 GET /ProjectFE/ 的映射”

2024-01-08

正如标题所示,我收到一个错误[org.springframework.web.servlet.PageNotFound] (default task-1) No mapping for GET /ProjectFE/我应该如何解决这个问题?另外,代码中没有错误。

这是我的代码:

web.xml 文件-

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<!-- The definition of the Root Spring Container shared by all Servlets 
    and Filters -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/spring-config.xml
    </param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Processes application requests -->
<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-config.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

spring-config.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc.xsd
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd">

<annotation-driven />

<resources mapping="/resources/**" location="/resources/" />

<beans:bean 
 class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/views/" />
    <beans:property name="suffix" value=".jsp" />
 </beans:bean>

     <context:component-scan    base-package="controller" />        

 </beans:beans>

homepage.java 文件:

package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class HomeController {
        @RequestMapping(value="/", method=RequestMethod.GET)
    public String home()
    {
       return "homepage";
    }

 }

在服务器上运行代码后,我得到的结果是:

17:59:10,772 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found ProjectFE.war in deployment directory. To trigger deployment create a file called ProjectFE.war.dodeploy
17:59:10,822 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "ProjectFE.war" (runtime-name: "ProjectFE.war")
17:59:15,226 WARN  [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0007: Not installing optional component org.springframework.http.server.reactive.ServletServerHttpResponse$ResponseAsyncListener due to an exception (enable DEBUG log level to see the cause)
17:59:15,227 WARN  [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0007: Not installing optional component org.springframework.http.server.reactive.ServletHttpHandlerAdapter$HandlerResultAsyncListener due to an exception (enable DEBUG log level to see the cause)
17:59:15,230 WARN  [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0007: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
17:59:15,231 WARN  [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0007: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
17:59:15,234 WARN  [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0007: Not installing optional component org.springframework.http.server.reactive.ServletServerHttpRequest$RequestAsyncListener due to an exception (enable DEBUG log level to see the cause)
17:59:15,251 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
17:59:15,252 WARN  [org.jboss.weld.deployer] (MSC service thread 1-5) WFLYWELD0013: Deployment ProjectFE.war contains CDI annotations but no bean archive was found (no beans.xml or class with bean defining annotations was present).
17:59:15,274 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = ProjectFE.war_org.h2.Driver_1_4
17:59:15,306 INFO  [io.undertow.servlet] (ServerService Thread Pool -- 74) No Spring WebApplicationInitializer types detected on classpath
17:59:15,308 INFO  [io.undertow.servlet] (ServerService Thread Pool -- 74) Initializing Spring root WebApplicationContext
17:59:15,308 INFO  [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 74) Root WebApplicationContext: initialization started
17:59:16,053 INFO  [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 74) Root WebApplicationContext initialized in 745 ms
17:59:16,057 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 74) Initializing Mojarra 2.2.13.SP5  for context '/ProjectFE'
17:59:17,076 INFO  [io.undertow.servlet] (ServerService Thread Pool -- 74) Initializing Spring DispatcherServlet 'appServlet'
17:59:17,076 INFO  [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 74) Initializing Servlet 'appServlet'
17:59:17,279 INFO  [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 74) Completed initialization in 203 ms
17:59:17,280 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 74) WFLYUT0021: Registered web context: '/ProjectFE' for server 'default-server'
17:59:17,353 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed "ProjectFE.war" (runtime-name : "ProjectFE.war")
18:00:14,061 WARN  [org.springframework.web.servlet.PageNotFound] (default task-1) No mapping for GET /ProjectFE/

project structure: enter image description here


首先要安排好你的web.xml像这样

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            WEB-INF/spring-config.xml
        </param-value>
    </context-param>
   <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

正如你所定义的contex-param你不需要使用init-param相同的 xml 文件。 现在稍微改变一下spring-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc.xsd
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd">

<mvc:annotation-driven/>

<resources mapping="/resources/**" location="/resources/" />

<beans:bean 
 class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/Views/" />
    <beans:property name="suffix" value=".jsp" />
 </beans:bean>

  <context:component-scan    base-package="controller" />        
 </beans:beans>

仔细看排队<beans:property name="prefix" value="/Views/" />。您的文件夹名称是Views但你定义了view。这就是为什么你可能会遇到错误。

如果有效的话请大声喊叫。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

收到警告“[org.springframework.web.servlet.PageNotFound](默认任务-1)没有 GET /ProjectFE/ 的映射” 的相关文章

  • NoInitialContextException:heroku 战争部署

    我一直在开发一个 J2EE 项目 并且在其中使用连接池 也通过部署在 heroku 上的数据库进行访问 我使用以下代码来设置 Connection 对象 Context initContext new InitialContext Cont
  • 删除优先级队列的尾部元素

    如何删除优先级队列的尾部元素 我正在尝试使用优先级队列实现波束搜索 一旦优先级队列已满 我想删除最后一个元素 优先级最低的元素 Thanks 没有简单的方法 将元素从原始元素复制到新元素 最后一个除外 PriorityQueue remov
  • 在 Struts 2 中传递 URL 参数而不使用查询字符串

    我想使用类似的 URL host ActionName 123 abc 而不是像这样传递查询字符串 host ActionName parm1 123 parm2 abc 我怎样才能在 Struts 2 中做到这一点 我按照下面的方法做了
  • Android 中 localTime 和 localDate 的替代类有哪些? [复制]

    这个问题在这里已经有答案了 我想使用从 android API 获得的长值 该值将日期返回为长值 表示为自纪元以来的毫秒数 我需要使用像 isBefore plusDays isAfter 这样的方法 Cursor managedCurso
  • 为自定义驱动程序创建 GraphicsDevice

    我正在开发一个在嵌入式系统中使用 Java 的项目 我有用于屏幕和触摸输入的驱动程序 以及用于文本输入的虚拟键盘 我的屏幕驱动程序有一个Graphics2D您可以绘制的对象和repaint Rectangle 更新方法 类似地 触摸驱动器能
  • Spring数据中的本机查询连接

    我有课 Entity public class User Id Long id String name ManyToMany List
  • 为什么Iterator接口没有add方法

    In IteratorSun 添加了remove 方法来删 除集合中最后访问的元素 为什么没有add方法来向集合中添加新元素 它可能对集合或迭代器产生什么样的副作用 好的 我们开始吧 设计常见问题解答中明确给出了答案 为什么不提供 Iter
  • 在 MongoDB 和 Apache Solr 之间同步数据的简单方法

    我最近开始使用 MongoDB 和 Apache Solr 我使用 MongoDB 作为数据存储 并且希望 Apache Solr 为我的数据创建索引 以实现应用程序中的搜索功能 经过一些研究 我发现 基本上有两种方法可以在 MongoDB
  • 当 minifyEnabled 为 true 时 Android 应用程序崩溃

    我正在使用多模块应用程序 并且该应用程序崩溃时minifyEnabled true in the installed模块的build gradle 以下是从游戏控制台检索到的反混淆堆栈跟踪 FATAL EXCEPTION Controlle
  • Java:如何确定文件所在的驱动器类型?

    Java 是否有一种独立于平台的方法来检测文件所在的驱动器类型 基本上我有兴趣区分 硬盘 可移动驱动器 如 USB 记忆棒 和网络共享 JNI JNA 解决方案不会有帮助 可以假设 Java 7 您可以使用 Java 执行 cmd fsut
  • Java - 从 XML 文件读取注释

    我必须从 XML 文件中提取注释 我找不到使用 JDOM 或其他东西来让它们使用的方法 目前我使用 Regex 和 FileReader 但我不认为这是正确的方法 您可以使用 JDOM 之类的东西从 XML 文件中获取注释吗 或者它仅限于元
  • 我可以限制分布式应用程序发出的请求吗?

    我的应用程序发出 Web 服务请求 提供商处理的请求有最大速率 因此我需要限制它们 当应用程序在单个服务器上运行时 我曾经在应用程序级别执行此操作 一个对象跟踪到目前为止已发出的请求数量 并在当前请求超出允许的最大负载时等待 现在 我们正在
  • 如何让 Emma 或 Cobertura 与 Maven 一起报告其他模块中源代码的覆盖率?

    我有一个带有 Java 代码的多模块 Maven 设置 我的单元测试在其中一个模块中测试多个模块中的代码 当然 这些模块具有相互依赖性 并且在测试执行之前根据需要编译所有相关模块中的代码 那么 如何获得整个代码库覆盖率的报告 注意 我不是问
  • 如何处理 StaleElementReferenceException

    我正在为鼠标悬停工作 我想通过使用 for 循环单击每个链接来测试所有链接的工作条件 在我的程序中 迭代进行一次 而对于下一次迭代 它不起作用并显示 StaleElementReferenceException 如果需要 请修改代码 pub
  • Hadoop NoSuchMethodError apache.commons.cli

    我在用着hadoop 2 7 2我用 IntelliJ 做了一个 MapReduce 工作 在我的工作中 我正在使用apache commons cli 1 3 1我把库放在罐子里 当我在 Hadoop 集群上使用 MapReduceJob
  • JMS 中的 MessageListener 和 Consumer 有什么区别?

    我是新来的JMS 据我了解Consumers能够从队列 主题中挑选消息 那么为什么你需要一个MessageListener因为Consumers会知道他们什么时候收到消息吗 这样的实际用途是什么MessageListener 编辑 来自Me
  • 何时在 hibernate 中使用 DiscriminatorValue 注解

    在 hibernate 中使用 DiscriminatorValue 注释的最佳场景是什么以及何时 这两个链接最能帮助我理解继承概念 http docs oracle com javaee 6 tutorial doc bnbqn html
  • 使用 JFreeChart 为两个系列设置不同的 y 轴

    我正在使用 JFreeChart 使用折线图绘制两个数据系列 XYSeries 复杂的因素是 其中一个数据系列的 y 值通常远高于第二个数据系列的 y 值 假设第一个系列的 y 值约为数百万数量级 而第二个数据系列的 y 值约为数百万数量级
  • 检查应用程序是否在 Android Market 上可用

    给定 Android 应用程序 ID 包名称 如何以编程方式检查该应用程序是否在 Android Market 上可用 例如 com rovio angrybirds 可用 而 com random app ibuilt 不可用 我计划从
  • 基于 Spring Boot 的测试中的上下文层次结构

    我的 Spring Boot 应用程序是这样启动的 new SpringApplicationBuilder sources ParentCtxConfig class child ChildFirstCtxConfig class sib

随机推荐

  • 从 C# 调用包含函数指针的 DLL 函数

    我有一个用 C 编写的 DLL 其中包含导出函数 该函数具有用作回调函数的函数指针 C DllExport unsigned int DllFunctionPointer unsigned int i unsigned int TimesT
  • Phantomjs Function.prototype.bind

    对我知道那个 Phantomjs 不支持函数绑定 但也许我可以用别的东西 或者说page open不使用bind 看起来还可以 但是有些网站 返回错误 TypeError undefined is not a function evalua
  • Windows 上的 Python - 如何等待多个子进程?

    如何在 Windows 上的 Python 中等待多个子进程 而不需要主动等待 轮询 像这样的东西almost对我有用 proc1 subprocess Popen python mytest py proc2 subprocess Pop
  • 如何获取传递给函数的变量的原始变量名[重复]

    这个问题在这里已经有答案了 是否可以获取传递给函数的变量的原始变量名 例如 foobar foo def func var print var origname So that func foobar Returns gt gt fooba
  • 警报管理器 2 次

    我有一个BroadcastReceiver called AlarmReceiver that Toasts 警报工作了 我正在尝试设置重复PendingIntent引起AlarmReceiver5 45 和 17 30 但在启动应用程序几
  • grails:如何更改编译的 GSP(gsp*.class 文件)?

    我在 weblogic 中使用 grails 需要更改展开的部署文件夹中的类文件 但这个类实际上是一个gsp编译的文件 那么 问题是 GSP 文件 class 在战争中留在哪里 注意 我正在使用外部 GSP 设置grails gsp vie
  • Google 图表 API JSON 无效

    以下代码返回 Google 图表的 json public static DataTable generateDataTable Create a data table DataTable data new DataTable ArrayL
  • 使用本地化日期进行 Django 查询

    在我的表单中 我有一个名为 booking date 的 DateField 它是使用 AdminDateWidget 呈现的 booking date字段的内容需要国际化 当我想像这样使用字段的值时 就会出现问题 booking Book
  • 访问或获取静态类中的 Autofac Container

    我需要在静态类中获取或访问我的 IoC 容器 这是我的 简化的 场景 我在 Startup 类中注册 ASP net Web Api 的依赖项 而且我也为 MVC 或 WCF 执行此操作 我有一个 DependecyResolver 项目
  • 如何从可变大小的字符串中获取所需的字符?

    我需要提取附加到该单词的所需字符串 例如 pot 1 Sam pot 22 Daniel pot 444 Jack pot 5434 Bill 我需要从上面的字符串中获取名称 即萨姆 丹尼尔 杰克和比尔 问题是 如果我使用子字符串 由于数字
  • git ls-带日期的文件?

    在 GitHub 上 每个文件夹页面上都有这个很好的功能 它列出了文件名以及上次提交该文件的时间 这类似于ls l命令 有没有办法从命令行模仿这种行为 就像是 git ls files l 基于sjas 回答 https stackover
  • mySQL 专家 - 需要“相交”方面的帮助

    我知道 mySQL 5 x 不支持 INTERSECT 但这似乎正是我所需要的 表 A 产品 p id 表 B Prod cats cat id 类别信息 名称 描述等 表 C prod 2cats p id cat id 多对多 prod
  • Android:将父状态传播到子视图

    我遇到了一些我基本上不知道如何解决的问题 我有一个 LinearLayout 里面有一些子组件 如 ImageView TextView 等 可以在下面的 xml 中看到一个示例
  • 为什么我的页眉周围有空白且没有颜色?

    我试图填满整个
  • bash 命令输出作为参数

    假设命令alpha产生这个输出 a b c d 如果我运行命令 beta alpha then beta将使用四个参数执行 a b c and d 但是如果我运行命令 beta alpha then beta将使用一个参数执行 a b c
  • UIWebView 和 Safari 比较

    UIWebView 是否使用与 Mobile Safari 相同的 JavaScript 引擎 另外 UIWebView 是否像 Mobile Safari 一样支持所有 HTML5 功能 我特别关心 Web SQL 和 Web Worke
  • Android 短划线/虚线问题?

    当我使用时Android 虚线 its 在小屏幕上运行良好 but 不适用于 Samsung S3 设备及更高版本 截图 And 可绘制 dashline xml
  • 如何在 VSTS 中使用 NUnit?

    我正在尝试在 Visual Studio Team System 中使用 NUnit 3 但他们似乎让这变得非常困难 我已在构建过程和高级执行选项中添加了测试程序集步骤 gt 自定义测试适配器的路径 我已按照帮助中的建议放入 NUnitVi
  • 检查列表是否为空(Raku)

    常见问题解答 在 Raku 中如何检查列表是否为空 还有比以下更惯用的方法吗 my l say l elems 0 say l say l Bool The 名单上的文档 https docs perl6 org type List推荐智能
  • 收到警告“[org.springframework.web.servlet.PageNotFound](默认任务-1)没有 GET /ProjectFE/ 的映射”

    正如标题所示 我收到一个错误 org springframework web servlet PageNotFound default task 1 No mapping for GET ProjectFE 我应该如何解决这个问题 另外 代