<html>
<body>
<input id="customerId" >
<input id ="address" >
<input id="123" type="submit" >
</body>
<script src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$("-sharp123").click(function() {
$.ajax({
type: "POST",
url: "http://10.2.163.2:7001/chatClientService/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(GetJsonData()),
dataType: "json",
success: function (message) {
},
error: function (message) {
}
});
});
function GetJsonData() {
var json = {
"customerId": "7800071499",
"address": "10.2.162.2"
};
return json;
}
</script>
</html>
@Controller(value = "blackServiceAction")
@Scope("prototype")
public class BlackServiceAction extends ActionSupport {
private static final long serialVersionUID = -5155883818336614584L;
@Autowired
private BlackInfoDaoImpl blackInfoDao;
public String execute() throws ServletException, IOException {
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
InputStream ins = request.getInputStream();
InputStreamEntity entity = new InputStreamEntity(ins, 1024);
String requestContent = EntityUtils.toString(entity, "utf-8");
JSONObject requestJson = JSONObject.fromObject(requestContent);
try {
String customerId = requestJson.getString("customerId");
String address = requestJson.getString("address");
String result = isBlack(customerId,address);
response.getWriter().print(result);
} catch (Exception e) {
System.out.println(e);
}
return null;
}