2

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?

Community
  • 1
  • 1
213897
  • 1,561
  • 4
  • 15
  • 16
  • I don't quite follow you... maybe provide some example JSP code and explain how that is getting into the database? Have you tried plain links like: (if you don't need the host/domain part) – nickdos Feb 17 '11 at 01:10
  • it's an issue with me sending `${pageContext.request.contextPath}/mappings/here` to the server, then later adding another `${pageContext.request.contextPath}`. I was just curious if could parse that out somehow – 213897 Feb 17 '11 at 18:27

1 Answers1

2

From your last comment, yes the spring:url tag does have an option to exclude the contextPath portion of the URL. Just set the context attribute to an empty string:

<spring:url var="mappingLink" context="" value="/mappings/here" />

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.

nickdos
  • 8,348
  • 5
  • 30
  • 47