I'm working on a JSF 2.0 project using Mojarra, PrimeFaces and Tomcat 6.x.
I created some outputlink that point to files. These files are external of my WAR in a directory under Apache HTTPD's control.
<h:outputLink value="#{fileItem.linkTarget.sourceUrl}">#{fi开发者_StackOverflow社区leItem.boname} (#{fileItem.linkTarget.mediaType})</h:outputLink>
The sourceUrl is value like /dir/subDir/file.pdf
. When my sourceUrl doesn't contains space it's work. But when its contains space, they are are replace by +
.
/dir/subDir/big file.pdf
become /dir/subDir/big+file.pdf
. When i replace the +
with space in a normal webbrowser, it's work?
What's wrong and how can I fix it?
I get the same problem with graphicImage of mojarra and i solve by using Primefaces's graphicImage.
In general I would not recommend to use blank spaces in urls.
If you have no influence on the file names in the url's you should url-encode these names as described here URL-Encoding. The blank space has to be replaced by %20. Maybe there is a java class that does the encoding for you. I only know it from PHP, there you have a function like urlEncode().
精彩评论