У меня есть приложение весенней загрузки в качестве серверной части и приложение android в качестве интерфейса. Я попытался отправить запрос POST с залпом из приложения android, и это сработало. После того, как я добавил Spring Security, но теперь запрос POST не работает. Соединение установлено и идентификатор сеанса назначен, но RequestMapping не работает.
КЛИЕНТ:
try {
RequestQueue requestQueue = Volley.newRequestQueue(con);
String URL = "http://10.0.2.2:8080/registration/";
JSONObject jsonBody = new JSONObject();
jsonBody.put("Title", "Android Volley Demo");
jsonBody.put("Author", "BNK");
final String requestBody = jsonBody.toString();
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>()
{
@Override
public void onResponse(String response)
{
Log.i("VOLLEY", response);
}
}, new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
Log.e("VOLLEY", error.toString());
}
})
{
@Override
public byte[] getBody() throws AuthFailureError
{
try
{
return requestBody == null ? null : requestBody.getBytes("utf-8");
} catch (UnsupportedEncodingException uee)
{
VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", requestBody, "utf-8");
return null;
}
}
};
requestQueue.add(stringRequest);
} catch (JSONException e)
{
e.printStackTrace();
}
СЕРВЕР :
@RequestMapping(value = "/registration", method = RequestMethod.POST)
public String registration(@RequestBody String prova)
{
System.out.println(prova);
return "registration";
}