休息电话不工作

Rest Call in not working

我正在尝试使用 rest 调用,它获取 os 中的文件位置。 在 return 中,其余调用模拟文件的下载。

下面是代码

<div class="form-container">
        <h1>Welcome to CoinPay</h1>

        Click on below links to download Coin.<br /><br />

         <a href="<c:url value='/download/<%=request.getParameter("dest") %>' />">Coin Mobile
            Application</a>


    </div>

在参数 "dest" 中的值为 D:/coinFiles/Coin-v1.1.8.apk

其余调用定义如下

@RequestMapping(value="/download/{dest}", method = RequestMethod.GET)
    public void downloadFile(HttpServletResponse response, @PathVariable("dest") String dest) throws IOException {
}

出于某种原因,href 创建的 link 无法访问剩余调用。

我应该怎么做。任何帮助表示赞赏。 提前谢谢你。

由于您的 dest 变量的值中有正斜杠,因此首先您需要使用这样的注释在路径参数中启用斜杠

@RequestMapping(value = { "download/{dest:.+}" })

如果你想创建像 /download?dest=testDest 这样的链接,你可以使用 <c:param>

<c:url value="/download" var="myURL">
   <c:param name="dest" value="${dest}" />
</c:url>

<a href="${myURL}" />${myURL}</a>

请更换您的控制器。@RequestParam

@RequestMapping(value="/download", method = RequestMethod.GET)
public void downloadFile(HttpServletResponse response,@RequestParam("dest") String dest) {
     .......
}