Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Jersey可以将HeaderParam和FormParam注入类私有变量吗?_Java_Rest_Jersey - Fatal编程技术网

Java Jersey可以将HeaderParam和FormParam注入类私有变量吗?

Java Jersey可以将HeaderParam和FormParam注入类私有变量吗?,java,rest,jersey,Java,Rest,Jersey,我编写了以下代码: 公共类UserAccountWebServices{ @Context protected HttpHeaders httpHeaders; @HeaderParam("Authorization") private String authorization; @FormParam("UserAccountIdentifier") private String userAccountIdentifier; 问题是我的类变量(authorization和userAcco

我编写了以下代码:

公共类UserAccountWebServices{

@Context
protected HttpHeaders httpHeaders;

@HeaderParam("Authorization")
private String authorization;

@FormParam("UserAccountIdentifier")
private String userAccountIdentifier;

问题是我的类变量(authorization和userAccountIdentifier)被标记为“private”,IntelliJ IDEA标记了一个警告,表示它们从未被分配。在编译和运行它之前,我还有很长的路要走,所以如果有人能告诉我它是否可以工作,我将不胜感激-注入到私有变量中

谢谢!

是的,这很有效(假设您使用的是Jersey)。

是的,这很有效(假设您使用的是Jersey)