要求非常简单
1)在servlet doPost中使用字符串用户名的Preapre Gson - > PASS
String userName = "ABC123";
String username = new Gson().toJson(userName, String.class);
httpServletResponse.getWriter().write(username);
2)在jquery获取此用户名 - > FAIL
$.post('/XYZServlet', function(username) {
if(username != null) {
alert('i got username' + username) //here i am getting string as 'success'
var parsed = JSON.parse(username); //gives error
无法解析字符串用户名,有人可以帮忙吗?