1.get类型参数:
String icode = request.getParameter(“icode”);
2.获取body体

public class RequestBodyUtils {
private static final int BUFFER_SIZE = 1024 * 8;
/** * read string. * * @param reader Reader instance. * @return String. *
@throws IOException */ public static String read(Reader reader) throws
IOException { StringWriter writer = new StringWriter(); try { write(reader,
writer); return writer.getBuffer().toString(); } finally{ writer.close(); } }
/** * write. * * @param reader Reader. * @param writer Writer. * @return count.
* @throws IOException */ public static long write(Reader reader, Writer writer)
throws IOException { return write(reader, writer, BUFFER_SIZE); } /** * write.
* * @param reader Reader. * @param writer Writer. * @param bufferSize buffer
size. * @return count. * @throws IOException */ public static long write(Reader
reader, Writer writer, int bufferSize) throws IOException { int read; long
total = 0; char[] buf = new char[BUFFER_SIZE]; while( ( read = reader.read(buf)
) != -1 ) { writer.write(buf, 0, read); total += read; } return total; }
}
log.info("开始校验jwt---"); BufferedReader bufferedReader = request.getReader();
String bodyStr = RequestBodyUtils.read(bufferedReader);
log.info("bodyStr:{}",bodyStr); String jwt = null; try { jwt =
(String)JSONObjectUtils.parse(bodyStr).get("jwt"); log.info("jwt:{}",jwt); }
catch (Exception e) { e.printStackTrace(); } String
authenticationOfjwt=request.getHeader("jwt");
if(ObjectUtils.isEmpty(authenticationOfjwt)&&!ObjectUtils.isEmpty(jwt)){
response.setHeader("jwt",jwt); log.info("使用参数里的jwt"); }

技术
下载桌面版
GitHub
Gitee
SourceForge
百度网盘(提取码:draw)
云服务器优惠
华为云优惠券
腾讯云优惠券
阿里云优惠券
Vultr优惠券
站点信息
问题反馈
邮箱:[email protected]
吐槽一下
QQ群:766591547
关注微信