且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与Java Servlet中的json对象分开获取值

更新时间:2023-12-04 14:19:22

在您的servlet中,在do[Get,Post]()方法中执行以下操作

In your servlet, do the following in the do[Get,Post]() method

JSONObject jsonObject = JSONObject.fromObject( request.getQueryString() );  

String username= jsonObject.get( "username" );  
String password= jsonObject.get( "password" ); 
String type= jsonObject.get( "type" ); 

您还需要从JS中删除以下行.

You also need the remove the following line from your JS.

request = JSON.parse(data);