我已经使用 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 许可协议
我多次与这个问题作斗争。
我目前使用的解决方案是天气 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>
我一直看到问题中提到的错误。然而,将标签更改为如下所示的标签解决了这个问题。