码迷,mamicode.com
首页 > Web开发 > 详细

post表单、json接口

时间:2020-01-01 10:09:09      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:提交   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<MultipartFile> 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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!