源服务器没有找到目标资源的当前表示或不愿意透露存在的表示。关于部署到 tomcat

新手上路,请多包涵

我已经使用 Spring 和 Eclipse IDE 构建了一个应用程序。当我从 Eclipse IDE 启动项目时,一切都很好,但是当我将 maven 项目打包为 war 文件并部署到单独的 tomcat 时,我遇到了这个问题

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

这是我的 xml 文件中的配置片段

<!-- View Resolver -->
    <beans:bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/pages/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

我正在尝试访问此控制器

@RequestMapping(value = {"/welcome", "/"})
    public String defaultPage() {
            return "Web Service data successfuly consumed";

    }

有人知道为什么部署到tomcat失败了吗?

原文由 Blaze 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 760
1 个回答

我多次与这个问题作斗争。

我目前使用的解决方案是天气 web 应用程序(或您保存 jsp 等视图的文件夹)在部署程序集下。

为此 Right click on the project > Build Path > Configure Build path > Deployment Assembly > Add(right hand side) > Folder > (add your jsp 文件夹。默认情况下是 src/main/webapp )

在你做完所有正确的事情之后你也可能会得到这个错误但是在 JSP 上你把锚标记放在旧的时尚(如果它帮助其他人解决同样的问题,我添加这个 incase)。

我在 jsp 上有以下语法。 <a href="/mappedpath">TakeMeToTheController</a> 我一直看到问题中提到的错误。然而,将标签更改为如下所示的标签解决了这个问题。

 <a href=" <spring:url value="/mappedpath" /> ">TakeMeToTheController</a>

原文由 Tadele Ayelegn 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏