我已经使用 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>
我正在尝试访问此 Controller
@RequestMapping(value = {"/welcome", "/"})
public String defaultPage() {
return "Web Service data successfuly consumed";
}
有人知道为什么部署到 tomcat 失败?
最佳答案
我多次为这个问题苦苦挣扎。
我目前使用的解决方案是 webapp(或您保存 jsp 等 View 的文件夹)在部署程序集中。
这样做Right click on the project > Build Path > Configure Build path > Deployment Assembly > Add(right hand side) > Folder > (add your jsp
文件夹。默认情况下为 src/main/webapp
)
在你做所有正确的事情后,你也可能会得到这个错误,但是在 JSP 上你把 anchor 标记放在旧的时尚中(如果它帮助其他人解决同样的问题,我会添加这个以防万一)。
我在 jsp 上有以下语法。 <a href="/mappedpath">TakeMeToTheController</a>
我一直看到问题中提到的错误。但是将标签更改为如下所示的标签解决了这个问题。
<a href=" <spring:url value="/mappedpath" /> ">TakeMeToTheController</a>
关于java - 源服务器没有找到目标资源的当前表示或不愿意透露存在的表示。关于部署到 tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43590008/