Я получаю иногда, а иногда и не странную ошибку:
Error setting expression X with value [Ljava.lang.String;@......]
Иногда это происходит, а иногда нет. Это тихо раздражает. Ошибка иногда исходит от этого класса:
package com.coreRestaurant.menuItem;
import com.google.gson.Gson;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
public class MenuItemAction extends ActionSupport implements ModelDriven<MenuItem>{
private MenuItem menuItem = new MenuItem();
private final String DATABASE_PROBLEMS = "Error code : Database problems";
private String json;
public String execute(){
MenuItemService itemService = new MenuItemService();
if(itemService.testDatabaseConnectionU()){
setJson(new Gson().toJson(itemService.getMenuItemsByMenuId(menuItem.getMenuId()) ));
}else{
setErrorToBeSentBackToClientSide(DATABASE_PROBLEMS);
}
return SUCCESS;
}
@Override
public MenuItem getModel() {
return menuItem;
}
public String getJson() {
return json;
}
public void setJson(String json) {
this.json = json;
}
private void setErrorToBeSentBackToClientSide(String error){
String errorCode = error;
setJson(new Gson().toJson(errorCode));
}
}
А потом MenuItem
класс:
package com.coreRestaurant.menuItem;
public class MenuItem {
private String name;
private double price;
private int menuId;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getMenuId() {
return menuId;
}
public void setMenuId(int menuId) {
this.menuId = menuId;
}
public void setMenuId(MenuItem fromJson) {
setName(fromJson.getName());
setPrice(fromJson.getPrice());
}
}
И я вызываю эти вещи из файла PHP (две строки делают это, но вторая вызывает беспокойство):
$specificMenuJson = file_get_contents('http://localhost:8080/Core/read?id=' . $menuId);
$specificMenuItemsJson = file_get_contents('http://localhost:8080/Core/readMenuItemById?menuId=' . $menuId);
У него проблема с установкой значения menuId
, но у меня есть геттеры и сеттеры. Не знаю, почему иногда это не удается. Какие-либо предложения?