SpringSource IDE不会将项目名称用作Spring MVC应用程序的根URL [英] SpringSource IDE does not use project name as root URL for Spring MVC application

查看:141
本文介绍了SpringSource IDE不会将项目名称用作Spring MVC应用程序的根URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用SpringSource IDE创建Spring MVC模板项目时,我运行该应用程序,并将根URL设置为默认包名称的最后一个字:

When I create a Spring MVC Template Project with the SpringSource IDE, I run the application and the root URL is set as the last word of the default package name:

例如,当我创建项目时,我将默认程序包设置为com.sample.myapp.当我运行该应用程序时,它将在http://localhost:8080/myapp处打开.为什么根URL不使用我的项目名称MyProject代替?

For example, when I create the project, I set the default package as com.sample.myapp. When I run the application, it opens at http://localhost:8080/myapp. Why does the root URL not use my project name, MyProject, instead?

这是一个问题,因为我必须将应用程序中的所有URL都指定为/myapp/resources/css/mycss.css,但是当我导出.war并将其部署到Tomcat服务器时,Tomcat会改为使用项目名称(它希望我这样做使用/MyProject/resources/css/mycss.css.结果,在部署时我的所有链接都断开了(但是当我在SpringSource IDE中本地运行在Tomcat上时却没有断开)

This is a problem because I have to specify all of the URL's in my application to /myapp/resources/css/mycss.css but when I export a .war and deploy it to a Tomcat server, then Tomcat expects the project name instead (it wants me to use /MyProject/resources/css/mycss.css. As a result, all of my links are broken when I deploy (but not when I run on tomcat locally within the SpringSource IDE...)

还有其他人遇到这个问题吗?

Has anyone else run into this problem?

下面的评论讨论示例:

<bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
    <property name="service"
        value="https://localhost:8443/MyProject/j_spring_cas_security_check" />
    <property name="sendRenew" value="false" />
</bean>

推荐答案

这取决于您如何运行应用程序.我假设您从SpringSource IDE(STS)中选择了在服务器上运行"?如果双击STS中的服务器定义,则将看到模块"选项卡.从那里,您可以编辑路径"并将其设置为所需的任何值.当你选择服务器上运行",STS必须定义一个上下文路径,只是默认它为默认包的最后一个元素.如果我没记错的话,默认情况下,Tomcat使用压缩或展开的.war的文件名.无论哪种情况,您都可以改写.

It depends on how you run the application. I assume you chose "Run on Server" from within the SpringSource IDE (STS)? If you double click on the server definition in STS, you will see a "modules" tab. From there, you can edit the "Path" and set it to whatever you want. When you select "Run on Server", STS has to define a context path and simply defaults it to last element of the default package. If I recall correctly, by default Tomcat uses the file name name of the zipped or exploded .war. In either case, you can over-ride it.

希望有帮助.

这篇关于SpringSource IDE不会将项目名称用作Spring MVC应用程序的根URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆