我有一个使用 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 控制器类似于以下内容:
@Path("/api")
public class LoginResources {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("/login")
public void logIn(HttpServletRequest request) {
...
}
}
由于这个错误,我没有设法做到这一点:
HTTP Status 415 – Unsupported Media Type
任何想法??