在URL中传递base64加密字符串

时间:2015-05-19 03:26:35

标签: java spring-mvc base64 url-encoding

我想知道我是否可以在URL中传递base64加密的编码字符串。你能就此提出建议吗?

Ex:https://localhost:1234/sampleapp/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=/abcded.pdf

当我在Spring写这篇文章时,下面是我写的控制器:

 @Controller
 @RequestMapping("/sampleapp")
 public class ABC {

      @RequestMapping("/{encryptedText}/{fileName}")
      public bye[] streamContent(@PathVariable String encryptedText, @PathVariable String fileName){

      return ;
     }

 }  

1 个答案:

答案 0 :(得分:0)

是的,您可以,只要base64字符串是URL安全,这将替换非安全字符:=并删除Base64字符串的填充字符PreparedStatement ps = connection.prepareStatement(" SELECT o.id,o.itemId,userId, sum(I.price) as totalAmount FROM dbo.Orders o INNER JOIN dbo.Items I on o.itemId = I.id INNER JOIN dbo.Users u on o.UserId = u.Id WHERE o.id = ? GROUP BY o.id,o.itemId,u.userId"); ps.setInt(1, id);

我建议你使用这个apache Apache commons-codec库来编码/解码Base64 URL Strings

希望这有帮助,

何塞路易斯