How to access test000001
This is the description of my J2EE component This is the display name of my J2EE component StartServlet StartServlet 1 - & gt; StartServlet /StartServlet public class StartServlet extends the HttpServlet { Public StartServlet () Public void init () Public void test000001 () Public void test000002 () Public void test000003 () Public void test00000x () CodePudding user response:
Where is your caller? Through HTTP calls? A post from you look, you seem to be remote access HTTP service, then the client want to use httpclient
To access servlets, see the doGet, doPost implementation, the client using the get and post methods to visit
1 Since the launch of a servlet, generally is the origin place a singleton service class Do you want to visit since the launch of the method 1, the servlet best a new servlet, define the get/post methods pass parameters, then the new servlet to visit since the launch of the method 1 servlet CodePudding user response:
reference 1st floor tianfang response: what do you want to visit since the launch of the method 1, the servlet best a new servlet, define the get/post methods pass parameters, then the new servlet to visit since the launch of the method of the servlet 1 So, a servlet class a method only? Only inside the doget or dopost Aren't you ever call directly, This is too inflexible, srpingboot compared CodePudding user response:
If I have a class 20 method need external calls, Whether to build 20 servlet class to each callback CodePudding user response:
Can also put the method name as a parameter, so that a servlet can fix CodePudding user response:
Bosses can, for example, the method how to make parameter The web and how did the XML configuration, Url and how should pass, thank you CodePudding user response:
You make sure where are you calling, a (tomcat) external application via HTTP access? The fundamental problem not confirmed, say not bottom go to CodePudding user response:
refer to 6th floor tianfang response: you make sure where are you from call Directly from the browser Get agreement calls post, because he is an interface, Internal need not so complicated, CodePudding user response:
The title is not to say that, through HTTP access, the same class the following function, methods CodePudding user response:
Web service can access the url + get/post/put (pass parameters) interface, can't access the inner class, your question is wrong You need to define your own web interface, such as the get method: http://localhost/function0? Parmeter0=xxxx& Parmeter1=xxxx& Parmeter3=XXXX The interface name function0 (above) general in business function name; The get method limits is more, passing parameters with the post method is better, using json is basic to use restful specification CodePudding user response:
references 9 f tianfang response: your question is wrong Can't, You see somebody else tp framework, yii2 framework Which is not the name of the class/method name/http://localhost/ So directly can adjust function of the inner class web direct access to the I just want to ask is there any way to achieve through this web access To adjust the inner class function and the parameter to the function, CodePudding user response:
No route set of PHP, it is directly interface with the PHP file name, rather than the name of the class and method name, such as http://localhost/index.php CodePudding user response:
@ Override Protected void doGet (it the req, HttpServletResponse resp) throws ServletException, IOException { String method=request. The getParameter (" method "); {if (method="test000001") Test000001 (the req, resp); } . System. The out. Println (" doGet method is called "); Resp. GetOutputStream (). The write (" doGet method is called ". GetBytes ()); } @ Override Protected void doPost (it the req, HttpServletResponse resp) throws ServletException, IOException { System. The out. Println (" the doPost method is called the "); DoGet (the req, resp); } And at the front desk when http://localhost/request? Method=test000001... Test000002... test000003 CodePudding user response:
references to the tenth floor of the savage beast reply: Quote: references 9 f tianfang response: your question is wrong Can't, You see somebody else tp framework, yii2 framework Which is not the name of the class/method name/http://localhost/ So directly can adjust function of the inner class web direct access to the I just want to ask is there any way to achieve through this web access To adjust the inner class function and the parameter to the function, You can set the interceptors @ WebFilter (urlPatterns="/*") Public class TestFilter implements Filter { @ Override Public void doFilter (ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException { //TODO Auto - generated method stub It hrRequest=arg0 (it); String STR=hrRequest. GetServletPath (); System.out.println(str); nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull