当用户在EditTextbox中输入值'Nedskräpning'时,它将在数据库中保存为'Nedskräpning'。所以我假设这个错误是从应用程序的Android部分生成的。更新:< - 可能是错误的假设?
<EditText android:id="@+id/commentTextBox"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="1"/>
java代码:
commentTextBox = (EditText) findViewById(R.id.commentTextBox);
crapport.setComment(commentTextBox.getText().toString());
然后,此支持将保存在数据库中。
有关如何解决此问题的任何提示?
更新:这是我的Apache CXF网络服务:
@Path("/crapportService/")
public class CrapportServiceImpl implements CrapportService {
@Autowired
private CrapportController crapportController;
@Override
@Path("image")
@POST
@Produces(MediaType.TEXT_HTML)
public String addReport(MultipartBody multipartBody) {
List<Attachment> attachmentList = new ArrayList<Attachment>();
attachmentList = multipartBody.getAllAttachments();
if (attachmentList.size() == 0){
return "No attachments";
}
try {
crapportController.processReportFromClient(attachmentList);
} catch (FileNotFoundException e) {
e.printStackTrace();
return "Error: FileNotFoundException";
} catch (NullPointerException e) {
return "Error: NullPointerException";
} catch (IOException e) {
return "Error: IOException";
}
return "Success";
}
}
答案 0 :(得分:3)
我认为您的数据库使用ISO-8859-15或ISO-8859-1作为编码,Android中的字符串是UTF-8,如果存储在数据库中,则UTF-中的高位字和低位字8“Ä”被分成两个ISO-8859-1对应物,使其成为“Ô。
答案 1 :(得分:2)
通过将字符编码参数传递给字符串创建来解决它。 例如,后端应用程序的控制器部分中的新String(“values”,Charset.forName(“UTF-8”))。