Created
March 25, 2014 01:39
-
-
Save daichan4649/8409589f80c5253ad973 to your computer and use it in GitHub Desktop.
Jersey Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.QueryParam; | |
// http://localhost:8080/JerseySample/sample/hello?name=aaa&age=100 | |
@Path("/hello") | |
public class HelloResource { | |
@GET | |
public String say(@QueryParam("name") String name, | |
@QueryParam("age") String age) { | |
return String.format("name=%s, age=%s", name, age); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://java.sun.com/xml/ns/javaee" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" | |
id="WebApp_ID" version="3.0"> | |
<display-name>JerseySample</display-name> | |
<welcome-file-list> | |
<welcome-file>index.html</welcome-file> | |
<welcome-file>index.htm</welcome-file> | |
<welcome-file>index.jsp</welcome-file> | |
<welcome-file>default.html</welcome-file> | |
<welcome-file>default.htm</welcome-file> | |
<welcome-file>default.jsp</welcome-file> | |
</welcome-file-list> | |
<servlet> | |
<servlet-name>JerseySample</servlet-name> | |
<servlet-class> | |
org.glassfish.jersey.servlet.ServletContainer | |
</servlet-class> | |
<init-param> | |
<param-name>jersey.config.server.provider.packages</param-name> | |
<param-value>test</param-value> | |
</init-param> | |
<load-on-startup>1</load-on-startup> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>JerseySample</servlet-name> | |
<url-pattern>/sample/*</url-pattern> | |
</servlet-mapping> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment