Write API interface, summed up, but this splicing URL of the way, do not know whether it can be used as an API interface to obtain data
First add such a configuration to Web. xml
<!--test-
<servlet>
<servlet-name>BrandServlet</servlet-name>
<servlet-class>com.test.servlet.testa</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>BrandServlet</servlet-name>
<url-pattern>/jiekou.a</url-pattern>
</servlet-mapping>
<!--Test Junction--
Then fill in the code with the method
1 PackageCom.test.servlet;2 Importjava.io.IOException;3 ImportJava.io.PrintWriter;4 5 Importjavax.servlet.http.*;6 7 Public classTestaextendsHttpServlet {8 @Override9 Public voiddoget (httpservletrequest rq,httpservletresponse res) {Ten One Try { AString s= Rq.getparameter ("a"). toString (); -Res.setcharacterencoding ("UTF-8"); -PrintWriter pw=Res.getwriter (); the -Pw.write ("Canshu:" +s);//go to JSON - pw.close (); -}Catch(IOException e) { + //TODO auto-generated Catch block -E.printstacktrace ();// + } A } at}
View Code
Visit the URL http://localhost:8080/(your own project name)/jiekou.a?a=zhong several access to
Canshu:zhong
Java Write get Access data (springmvc+spring ... )