原始服务器找不到目标资源的当前表示,或者不愿意透露该资源的存在在部署到tomcat

浏览:47日期:2024-03-12
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解决原始服务器找不到目标资源的当前表示,或者不愿意透露该资源的存在在部署到tomcat?

如果你正在开发Spring Boot应用程序,请在主文件中添加“ SpringBootServletinitializer”,如以下代码所示。因为如果没有SpringBootServletinitializer,Tomcat会将其视为普通应用程序,则不会将其视为Spring引导应用程序。

@SpringBootApplicationpublic class DemoApplication extends *SpringBootServletinitializer*{ @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(DemoApplication .class); } public static void main(String[] args) { SpringApplication.run(DemoApplication .class, args); }}

我为此问题挣扎过很多次。

我当前使用的解决方案是在webapp(或保存了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上,你将锚标记放置为旧的样式(如果有其他问题,我会添加此标签以防其他人)。

我在jsp上具有以下语法。<a href='https://www.6hehe.com/mappedpath'>TakeMetoTheController</a>而且我一直看到问题中提到的错误。但是,将标签更改为如下所示的标签可以解决此问题。

<a href='https://www.6hehe.com/wenda/ <spring:url value='/mappedpath' /> '>TakeMetoTheController</a>解决方法

我已经使用带有Eclipse IDE的Spring构建了一个应用程序。当我从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:beanclass="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时会失败吗?

相关文章: