servletrest

A simple, light-weighted, easy-to-use restful servlet framework for JAVA.

License

License

GroupId

GroupId

org.maptalks
ArtifactId

ArtifactId

servletrest
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

servletrest
A simple, light-weighted, easy-to-use restful servlet framework for JAVA.
Project URL

Project URL

https://github.com/MapTalks/servletrest
Source Code Management

Source Code Management

https://github.com/MapTalks/servletrest

Download servletrest

How to add to project

<!-- https://jarcasting.com/artifacts/org.maptalks/servletrest/ -->
<dependency>
    <groupId>org.maptalks</groupId>
    <artifactId>servletrest</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.maptalks/servletrest/
implementation 'org.maptalks:servletrest:1.0.0'
// https://jarcasting.com/artifacts/org.maptalks/servletrest/
implementation ("org.maptalks:servletrest:1.0.0")
'org.maptalks:servletrest:jar:1.0.0'
<dependency org="org.maptalks" name="servletrest" rev="1.0.0">
  <artifact name="servletrest" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.maptalks', module='servletrest', version='1.0.0')
)
libraryDependencies += "org.maptalks" % "servletrest" % "1.0.0"
[org.maptalks/servletrest "1.0.0"]

Dependencies

provided (1)

Group / Artifact Type Version
javax.servlet : servlet-api jar 2.5

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

servletrest

Circle CI

A simple, light-weighted, easy-to-use restful servlet framework for JAVA.

it is very simple to configure restservlet, including 2 steps:

step 1: configure restservlet in web.xml to handle all the requests with a common prefix of the url, for example: http://foo.com/foo/rest/*

	<servlet>
		<servlet-name>RestServlet</servlet-name>
		<servlet-class>cn.com.seegoo.servletrest.RestServlet</servlet-class>
		<init-param>
			<param-name>ServletConfig</param-name>  
			<param-value>/servletconfig.xml</param-value>  
		</init-param> 
		<init-param>
			<param-name>Encoding</param-name>  
			<param-value>UTF-8</param-value>  
		</init-param>
		<load-on-startup>1</load-on-startup>     
	</servlet>
	<servlet-mapping>   
		<servlet-name>RestServlet</servlet-name>
		<url-pattern>rest/</url-pattern>
	</servlet-mapping>

step2: create some url patterns in a file named servletconfig.xml to match request url with a certain servlet class. save servletconfig.xml in the root source folder which means servletconfig.xml will be copied in WEB-INF/classes.

	<?xml version="1.0" encoding="UTF-8"?>
	<servlets>
	<!--sample start -->
	<!-- this means HelloServlet will handle the url http://foo.com/foo/rest/hello -->
	<servlet class="com.foo.HelloServlet">
		<urlpattern value="/rest/hello"></urlpattern>
	</servlet>
	<!-- someone is a variable in url pattern whose value will be set to servlet instance's field with the same name "someone".-->
	<!-- for expample,http://foo.com/foo/rest/hello/john, you can get "john" in HelloToSomeoneServlet's field someone-->
	<servlet class="com.foo.HelloToSomeoneServlet">
		<urlpattern value="/rest/hello/{someone}"></urlpattern>
	</servlet>
	<!--sample end -->
	</servlets>
org.maptalks

MapTalks

Versions

Version
1.0.0