【发布时间】:2021-01-04 02:41:08
【问题描述】:
我有一个使用 Postman 发送的 POST 请求,如下所示:
标题:
Content-Type: x-www-form-url-encoded
Content-Length: calculated when request is sent
Host: calculated when request is sent
User-Agent: PostmanRuntime/7.26.5
Accept: */*
Accept-Encoding: gzip, deflate, br
Connection: Keep-Alive
主体:
Key Value
---------------------------------------------
Value ASDSFSDFDSFSDFSDFS..[ecc]
到目前为止,我能够将请求发送到 .jsp 构建,如下所示:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
....
现在我想将这个POST Request 发送到Jersey REST Controller 到我的webapp; REST Controller 类似如下:
@Path("/api")
public class LoginResources {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("/login")
public void logIn(HttpServletRequest request) {
...
}
}
因为这个错误,我没能做到这一点:
HTTP Status 415 – Unsupported Media Type
有什么想法吗??
【问题讨论】:
标签: rest jersey http-status-code-415 x-www-form-urlencoded