簡體   English   中英

將查詢參數的值傳遞給字符串是錯誤的

[英]Passing the value of query param to string is error

我正在從事掃描車牌號的同一個項目。 我想要做的是將輸入的車牌號的值傳遞給字符串,以便我可以將它用於我的其他類。 另一類是顯示輸入車牌號的詳細信息。 在platenumbercheck.java 上是我想掃描platenumber 輸入的類。 我想將它傳遞給 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;
}   

}

joc = 檢查(taxi_plate_no); 這行不通,你不能調用這樣的函數 put joc=sagot; 內部函數“檢查”,它應該可以工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM