小编Rag*_*dra的帖子

带有混合多部分请求的@RequestPart,Spring MVC 3.2

我正在开发基于Spring 3.2的RESTful服务.我正面临一个控制器处理混合多部分HTTP请求的问题,第二部分使用XML或JSON格式化数据,第二部分使用图像文件.

我正在使用@RequestPart注释来接收请求

@RequestMapping(value = "/User/Image", method = RequestMethod.POST,  consumes = {"multipart/mixed"},produces="applcation/json")

public
ResponseEntity<List<Map<String, String>>> createUser(
        @RequestPart("file") MultipartFile file, @RequestPart(required=false) User user) {

    System.out.println("file" + file);

    System.out.println("user " + user);

    System.out.println("received file with original filename: "
            + file.getOriginalFilename());

    // List<MultipartFile> files = uploadForm.getFiles();
    List<Map<String, String>> response = new ArrayList<Map<String, String>>();
    Map<String, String> responseMap = new HashMap<String, String>();

    List<String> fileNames = new ArrayList<String>();

    if (null != file) {
        // for (MultipartFile multipartFile : files) {

        String fileName = file.getOriginalFilename(); …
Run Code Online (Sandbox Code Playgroud)

rest spring multipartform-data

14
推荐指数
3
解决办法
4万
查看次数

请帮助 - 阻止无效的密钥异常

我收到java.security.InvalidKeyException:非法的密钥大小或默认参数,我已经休闲所有必需的步骤,安装Java密码学扩展(JCE)无限强度管辖政策文件.我也已经通过这些线程了

Java.security.InvalidKeyException:非法密钥大小或默认参数错误

Java安全:非法密钥大小或默认参数?

但我仍然卡住并得到java.security.InvalidKeyException:非法的密钥大小或默认参数,

下面是我的代码:AESKeyGenerator.java

public class AESKeyGenerator {

    private Cipher mCipher;

    public AESKeyGenerator()
    {
        // default constructor
    }


    public byte[] generate_k(String dhkey, String toEncrypt)
    {
        byte[] retVal;

        try { // Set up the Cipher class of Android to use AES to generate keys
            byte[] iv = new byte[16];
            for (int i = 0; i < iv.length; i++)
                iv[i] = new Byte("0").byteValue();
            IvParameterSpec ivspec = new IvParameterSpec(iv);
            mCipher = Cipher.getInstance("AES");
            // Set up key to use in algorithm
            MessageDigest hasher …
Run Code Online (Sandbox Code Playgroud)

java security cryptography aes public-key-encryption

6
推荐指数
1
解决办法
8776
查看次数