2013-06-25 22 views
1

嗨,我試圖讓一個請求參數是一個URL文件路徑:的Java Servlet的1.3對的getParameter一個PARAM這是一個URL

我使用的是從XSL文件模板「粘貼」一個DIV與onclick事件:

<div onclick="openPDF(700,500,'getDoc?pathpdf={./.}&amp;type=pdf&amp;nocache='+Math.random(),'scrollbars=yes,toolbar=no,status=yes,resizable=yes,menubar=no,location=no');" align="center"> 
<img src='Images/pdfIconsmall.png' width='12' style='height:12' /> 
</div> 

本部 - > pathpdf = {./}將收到的URL像這樣:

pathpdf = \\ SERVER02 \工作\ 51區\文檔\ WS \ 00120130000261_101912 .pdf

the pa rameter被送到了預期,但在服務器端,當我嘗試做一個System.out的那個參數我正在跟此值的 :

- > - > - >路徑:SERVER02workarea51docsws 00120130000261_101912.pdf

是由servlet進行轉義還是在我的應用程序中執行這些操作?

謝謝

編輯

我以不同的方式從下面的answear但類似的使這個:string-replace-all

<xsl:when test="string-length(./.) &gt;0"> 
    <xsl:variable name="pathpdf"> 
     <xsl:call-template name="string-replace-all"> 
     <xsl:with-param name="text" select="./." /> 
     <xsl:with-param name="replace" select="'\'" /> 
     <xsl:with-param name="by" select="'\\'" /> 
      </xsl:call-template> 
    </xsl:variable> 
<div onclick="openPDF(700,500,'getDoc?pathpdf={$pathpdf}&amp;type=pdf&amp;nocache='+Math.random(),'scrollbars=yes,toolbar=no,status=yes,resizable=yes,menubar=no,location=no');" align="center"> 
<img src='Images/pdfIconsmall.png' width='12' style='height:12' /> 
</div> 
</xsl:when> 
+0

查看我的更新 – BackSlash

回答

4

你必須在發送之前的URL參數值編碼請求到服務器。

pathpdf=\SERVER02\work\area51\docs\ws\00120130000261_101912.pdf 

需求,成爲本:

pathpdf=%5CSERVER02%5Cwork%5Carea51%5Cdocs%5Cws%5C00120130000261_101912.pdf 

如果從Java應用程序與

URLEncoder.encode(parameterValue); 


提交請求,編碼的所有參數使用XSLT ,請嘗試:

url:encode('your_url_goes_here'); 
+0

謝謝BackSlash。實際上,我設法以不同的方式做到了這一點,但類似。我將用更新編輯我的問題。 –

相關問題