我在 MFP 的 javaAdpter 中遇到问题。 代码不执行 if 语句..我没有找到任何原因。
/* Path for method: "<server address>/Trail-Proejct1/adapters/TestAD/users/{username}" */
@GET
@Path("/{username}")
public String helloUser(@PathParam("username") String name){
if(name == "mfp"){
return "good moring" + name;
}
return "good afternoon " + name;
}
[2016-08-09 10:25:41] Adapter build and deploy finished.
[2016-08-09 10:25:59] Starting procedure invocation on MobileFirst Server
[2016-08-09 10:25:59] Not deploying adapter 'TestAD' since it was not changed since last deployment
[2016-08-09 10:25:59] Invoking procedure: '/Trail-Proejct1/adapters/TestAD/users/{username}' of adapter 'TestAD'
[2016-08-09 10:25:59] Server host: Banglafires-MacBook-Pro.local
[2016-08-09 10:25:59] Server port: 10080
[2016-08-09 10:25:59] Parameters: {"QUERY":{},"BODY":"","FORM":{},"HEADER":{},"PATH":{"username":"mfp"}}
[2016-08-09 10:25:59] Procedure invocation finished
最佳答案
尝试
if ("mfp".equals(name)) {
在Java中,==
用于检查两个引用是否指向同一个对象,而不是检查内容是否相同。
关于java 适配器不适用于条件检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38842112/