با درود و ادب
دوستان من در حال نوشتن یه برنامه با جرسی و هایبرنیتم که داده ها را بگیره و با دیتابیس کارهایی روشون انجام بده و پاسخ رو برگردونه.
خب حالا مشکل من اینجاست وقتی من داده های را در کروم با add on اون که POSTMAN هست ، ارسال می کنم سرور نمیتونه داده فارسی رو بفهمه!
ممنون میشم بتونید راهنماییم کنید.
با سپاس
این متد تستم در Junit
@Test public void testSearchObject(){
BranchLocationSearchClient client = new BranchLocationSearchClient();
List<String> searchValues = new ArrayList<String>();
searchValues.add("سازمان جهاد");
BranchLocationSearch search = new BranchLocationSearch();
search.setBranchNames(searchValues);
search.setBranchCodeFrom(2016);
search.setBranchCodeTo(2077);
search.setSearchType(EnumBranchLocationSearchType. SEARCH_BY_BRANCH_CODE);
List<BranchLocation> branchLocations = client.searchByObject(search);
System.err.println("testSearchObject->branchLocations: "+branchLocations);
}
اینم متد کلاینتم :
public List<BranchLocation> searchByObject(BranchLocationSearch search) { URI uri = UriBuilder.fromUri(link)
.path("search/locations")
.build();
WebTarget target = client.target(uri);
Response response = target.request(MediaType.APPLICATION_JSON)
.post(Entity.entity(search, MediaType.APPLICATION_JSON));
if(response.getStatus()!=200){
throw new RuntimeException(response.getStatus()+getClass().g etName()+": There is an error on server!");
}
return response.readEntity(new GenericType<List<BranchLocation>>(){});
}
اینم متد Resourceم
@POST
@Consumes(MediaType.APPLICATION_JSON)//";charset=utf-8"
@Produces({MediaType.APPLICATION_JSON,MediaType.AP PLICATION_XML})
public Response searchFroBranch(BranchLocationSearch search) throws Exception{
//http://localhost:8080/exercise-services/webapi/search/locations/
System.err.println(getClass().getSimpleName()+"->"+"searchFroBranch: "+search);
List<BranchLocation> branchLocationes = branchLocationDAO.findByConstraints(search);
if(branchLocationes==null || branchLocationes.size()<1){
return Response.status(Status.NOT_FOUND).entity("!ERROR NOT FOUND IN DB").build();
}
return Response.ok().entity(new GenericEntity<List<BranchLocation>>(branchLocation es){} ).build();
}