I am working on simple Spring-MVC application(Not Maven) where I want to make a web service which returns a boolean but it gives a HTTP Status 406 – Not Acceptable error. Also I am trying to call a it from a JSP.
JSP :
<form action="${pageContext.request.contextPath}/getformatretension" method="post" id="form">
<p>
loc 1: <input type="text" name="srcUrl" size="45" id="file" />
</p>
<p>
loc 2 : <input type="text" name="xlfUrl" size="45" id="xlffile"/>
</p><input type="Submit" value = "Submit">
</form>
Controller :
public class MyClassController {
@RequestMapping(value = "/getformatretension", method = RequestMethod.POST)
public ResponseEntity<Boolean> methodName(@RequestParam("srcUrl") String srcUrl
,@RequestParam("xlfUrl") String xlfUrl) throws IOException{
int nReturnVal = JsoupParserHtml.test(xlfUrl, srcUrl);
String mimeType= "text/plain;charset=UTF-8";
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", mimeType);
if(nReturnVal == 1)
{
System.out.println("Success");
return new ResponseEntity<Boolean>(true,HttpStatus.OK);
}
else {
System.out.println("error");
return new ResponseEntity<Boolean>(false,HttpStatus.BAD_REQUEST);
}
}
Error :
HTTP Status 406 – Not Acceptable
Type Status Report
Description The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation.