【问题标题】:Passing the value of query param to string is error将查询参数的值传递给字符串是错误的
【发布时间】:2015-06-21 05:08:12
【问题描述】:

我正在从事扫描车牌号的同一个项目。我想要做的是将输入的车牌号的值传递给字符串,以便我可以将它用于我的其他班级。另一个类是显示输入的车牌号的详细信息。在 platenumbercheck.java 上是我要扫描车牌号输入的类。我想将它传递给 String joc,以便我可以将它用于我的第二堂课 displaytaxidetails。

这是 platenumbercheck.java

package com.taxisafe.server;

import java.util.ArrayList;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.google.gson.Gson;
import com.taxisafe.array.ArrayConnection;
import com.taxisafe.connection.DatabaseConnection;
import com.taxisafe.json.JsonConstruction;
import com.taxisafe.objects.Objects;


//PATH FOR CHECKING PLATE NUMBER

@Path("platecheck")  //for the url

public class PlateNumberCheck {


String joc = check(taxi_plate_no);  //here's the variable I want to pass the platenumber 

@GET 
@Path("/check")
@Produces(MediaType.APPLICATION_JSON) 


public String check(@QueryParam("taxi_plate_no") String taxi_plate_no){

String sagot = "";

if(checkInput(taxi_plate_no)){
    sagot = JsonConstruction.JSONResponse("checked", true);
} else{ 
    sagot = JsonConstruction.JSONResponse("checked", false, "Not in the database");
}
return sagot;

}


private boolean checkInput (String taxi_plate_no){
System.out.println("Check Input");
boolean output = false;
if(JsonConstruction.isNotNull(taxi_plate_no)){
    try{
        output = DatabaseConnection.checkPlate(taxi_plate_no);
    } catch (Exception e){
        output = false;
    }
} else{
    output = false;
}

return output;
}   

}

【问题讨论】:

    标签: java parameter-passing query-parameters


    【解决方案1】:

    joc = check(taxi_plate_no); 这不起作用,你不能调用这样的函数 把joc=sgot;在“检查”函数内部,它应该可以工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-02
      • 1970-01-01
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 2018-04-18
      • 1970-01-01
      相关资源
      最近更新 更多