Home > Back-end >  The List of the toArray method to print out the address of the object.
The List of the toArray method to print out the address of the object.

Time:10-01

Today when writing a logic code, because the front need to preach in the past in the form of an array, and is my dto objects, object inside the parcel is a list of few words, said that code:
Public class ProductDetailDto implements Serializable {
Private Integer proId.
Private String proTitle;
Private BigDecimal proPrice;

Private Integer proNumber;
Private Boolean proIsHot;
Private Boolean proIsNew;
Private BigDecimal proSalePrice;

Private List ImgList=new ArrayList<> (a);
Private List SizeList=new ArrayList<> (a);
Private List ColorList=new ArrayList<> (a);
}
This is the inside of the dto, for example, I want to preach the past sizeList become array in the past, should write like this:
ModelAndView ModelAndView=new ModelAndView ();
ProductDetailDto ProductDetailDto=productService. GetOneProductByProId (proId);
If (productDetailDto==null) {
return null;
} else {
ModelAndView. AddObject (" product ", productDetailDto);
ModelAndView. AddObject (" size ", productDetailDto getSizeList (). The toArray ());
ModelAndView. SetViewName ("/admin/product/chooseProductImg ");
}
Return modelAndView.
So write words, is not an error, but is an object to the front desk after object address:

I feel should be the object not to rewrite the toString method, but I don't know how to change, could you tell me how to solve this problem? If I don't want to use the method of toArray,
  • Related