appengine sees User as additional parameter

▼魔方 西西 提交于 2021-01-29 03:50:48

问题


I am using OAuth with my app-engine server. It's rather simple to do, simple add User as one of the parameters. But when I do I get the compile error

Multiple entity parameters. there can only be a single entity parameter per method...

@ApiMethod(path = "updateDocument", name = "updateDocument", httpMethod = ApiMethod.HttpMethod.POST)
public void updateDocument(User user, MyDocument input){
  ...
}

It works fine for the methods of the form

public MyBean sayHiUser(@Named("name") String name, User user)

It just doesn't work when I have custom objects like MyDocument.


回答1:


I have the feeling your User is not of type import com.google.appengine.api.users.User.

The documentation states that "there can only be a single entity parameter per method" (see https://cloud.google.com/appengine/docs/java/endpoints/parameter-and-return-types).

However "Any type except a parameter or injected type is considered an entity type" and com.google.appengine.api.users.User is of type "injected": so you should not have any problem normally, unless your User is not of this type.

Personaly I have methods like

public Customer insert(final User user, Customer customer, ...

which work perfectly well



来源:https://stackoverflow.com/questions/40221387/appengine-sees-user-as-additional-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!