post表单、json接口

2021-05-02 20:27

阅读:554

标签:提交   setting   multi   str   value   col   man   import   frame   

package com.lv.qggz.man.dhht.api.typesetting;

import com.lv.qggz.man.dhht.api.typesetting.vo.UVO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @Author: sh
* @Description: TypeSettingController
* @Date: 22:00 2019/12/31
*/
@Controller
@RequestMapping("/api/typesetting")
public class TypeSettingController {

/**
* POST json提交
* @param json
* @param request
* @return
*/
@RequestMapping(value = "/hello", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public String hello(@RequestBody String json, HttpServletRequest request) {
String head = request.getHeader("token");
System.out.println("head:" + head);
return json;
}

/**
* POST form表单,多附件提交
* @param uvo
* @param request
* @return
*/
@RequestMapping(value = "/word",method = RequestMethod.POST,produces = "application/json;charset=UTF-8",consumes = "multipart/form-data")
public String word(UVO uvo,HttpServletRequest request){
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
List files = multipartHttpServletRequest.getFiles("file");
System.out.println(uvo);
return null;
}
}

post表单、json接口

标签:提交   setting   multi   str   value   col   man   import   frame   

原文地址:https://www.cnblogs.com/sung1024/p/12127999.html


评论


亲,登录后才可以留言!