如何避免多次
我正在使用
因为我们的项目位于 domain/ProjectName/mappings/here
。我在这里发布了一些困惑: 如何使用domain/ProjectName/ProjectName/mappings/here
这样的 URL。我怎样才能避免这种情况?如果spring需要添加ProjectName
,它不是应该先检查它是否存在吗?
I'm working with <spring:url />
because our project is located at domain/ProjectName/mappings/here
. I posted about some confusion here: How to use <spring:url /> with an <a> tag? . Now the issue I'm having is because I'm saving the URLS to a database. So I get URLs like domain/ProjectName/ProjectName/mappings/here
. How can I avoid this? If spring needs to add ProjectName
, shouldn't it be able to check for it's existence first?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的上一条评论,是
spring:url
标记确实有一个选项可以排除 URL 的 contextPath 部分。只需将context
属性设置为空字符串:不过,我不确定这是否会解决您的问题,因为
spring:url
标记似乎不太可能添加 contextPath两次。这似乎更有可能发生在代码中的其他地方。不管怎样,这应该可以帮助你找到答案。From your last comment, yes the
spring:url
tag does have an option to exclude the contextPath portion of the URL. Just set thecontext
attribute to an empty string:I'm not sure this will fix your problem though, as it seems unlikely that the
spring:url
tag is adding the contextPath twice. That seems more likely to be happening somewhere else in your code. Either way this should help you find out.