When doing the API notification interface of the project, it is found that the asynchronous notification information sent to the other server is not available in the SSH framework.
The last reason for troubleshooting may be that struts2 to the HttpServletRequest two times, then how to get the POST request data, a lot of methods, the following only one way.
A GET request in a servlet can get the full request path and request all the parameter lists through the HttpServletRequest Getrequesturl method and the GetQueryString ().
Post needs to be traversed by the Getparametermap () method, either get or post can be getrequesturl+getparametermap () to obtain the requested full path.
Packagecom.xxxImportjava.io.IOException;ImportJava.io.PrintWriter;ImportJava.util.Map;Importjavax.servlet.ServletException;ImportJavax.servlet.http.HttpServlet;Importjavax.servlet.http.HttpServletRequest;ImportJavax.servlet.http.HttpServletResponse; Public classGetparamsextendsHttpServlet {Private Static Final LongSerialversionuid = 1L; PublicGetparams () {Super(); } protected voiddoget (httpservletrequest request, httpservletresponse response)throwsservletexception, IOException {printwriter writer=Response.getwriter (); Writer.println ("GET" + request.getrequesturl () + "" +request.getquerystring ()); Map<string, string[]> params =Request.getparametermap (); String queryString= ""; for(String key:params.keySet ()) {string[] values=Params.get (key); for(inti = 0; i < values.length; i++) {String value=Values[i]; QueryString+ = key + "=" + Value + "&"; } } //remove the last spacequeryString = querystring.substring (0, Querystring.length ()-1); Writer.println ("GET" + request.getrequesturl () + "" +queryString); } protected voidDoPost (httpservletrequest request, httpservletresponse response)throwsservletexception, IOException {printwriter writer=Response.getwriter (); Map<string, string[]> params =Request.getparametermap (); String queryString= ""; for(String key:params.keySet ()) {string[] values=Params.get (key); for(inti = 0; i < values.length; i++) {String value=Values[i]; QueryString+ = key + "=" + Value + "&"; } } //remove the last spacequeryString = querystring.substring (0, Querystring.length ()-1); Writer.println ("POST" + request.getrequesturl () + "" +queryString); }}
According to the above code, a slight change, the implementation of the following:
/*** Get post data, do not support array form data, general use scenario is the other side use post to pass data over * TODO to perfect *@authorPhpdragon * @date 2014-12-24 pm 3:45:22 *@return* @description: *@returnmap<string,string> *@throws */@SuppressWarnings ("Unchecked") Private StaticMap<string, string>Getpostdata () {Map<string, string> param =NewHashmap<string, string>(); HttpServletRequest Request=servletactioncontext.getrequest (); Map<string, string[]> params =Request.getparametermap (); for(String key:params.keySet ()) {string[] values=Params.get (key); for(inti = 0; i < values.length; i++) {param.put (key, Values[i]); } } returnparam; }
Although it is not enough, the API interface scenario for the project in hand has already met the requirements.
In the SSH framework, how to get the URL and parameter list of the POST request