表单被提交两次到Jersey休息服务时出现500内部服务器错误

时间:2015-07-26 13:37:06

标签: java web-services rest jersey jersey-client

使用的客户端是一个简单的html表单,如下所示

<html>
<head>
<meta charset="ISO-8859-1">
<title>Weather Inputs</title>
</head>
<body>
<h1>The form </h1>
<form action= "rest/world/outlook" method="post">
Latitude : 
<input type ="text" name="lat">
Longitude :
<input type= "text" name="long">
<button type="submit">Submit</button>
</form>
</body>
</html>

POST请求在第一次成功时成功。但是,当表单刷新并再次使用时,它会抛出500错误。问题就像客户端破坏一样。 当使用Jersey客户端实现相同的客户端时,我可以使用client.destroy()方法来处理它。 这是Jersey客户端实现

try{     
     Form form = new Form();         
     form.add("lat",100);
     form.add("long",50);
     Client c = Client.create();
     WebResource web = c.resource("http://localhost:8080/ML_PoC_Project/rest/world/outlook");
     ClientResponse response = web.accept(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class,form);
     String output= response.getEntity(String.class);
     System.out.println(output);
     **c.destroy();**
     catch(Exception e)
     {
         e.printStackTrace();
     }

有人可以建议如何同样销毁html表单吗?

0 个答案:

没有答案