Skip to content

Latest commit

 

History

History

struts-rest-plugin

struts-examples Build Status

1.1. maven: webapp/pom.xml
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts2-rest-plugin</artifactId>
      <version>${struts2.version}</version>
    </dependency>
1.2. gradle: webapp/build.gradle
dependencies {
  compile "org.apache.struts:struts2-rest-plugin:$strutsVersion"
}
2. configure convention plugin: webapp/src/main/resources/struts.xml
  <constant name="struts.convention.action.suffix" value="Resource"/>
  <constant name="struts.convention.action.mapAllMatches" value="true"/>
  <constant name="struts.convention.default.parent.package" value="rest-default"/>
  <constant name="struts.convention.package.locators" value="rest"/>
3 rest controller
link:webapp/src/main/java/daggerok/rest/UserResource.java[role=include]
4 test
#

http :8080/webapp/

links:

build, run and test

embedded jetty (gradle gretty plugin)
./gradlew clean jettyRun
http :8080/
http :8080/user.json
http :8080/user.xml
http :8080/user/who-cares.json
build and run (JBoss in docker)
docker-compose down -v; ./mvnw; docker-compose up --build --force-recreate --remove-orphans
http :8080/webapp/
http :8080/webapp/user.xml
http :8080/webapp/user/49d3e5ce-20f9-41e4-965c-c945d71e41a8.json
embedded jetty (maven jetty plugin)
./mvnw -pl webapp clean jetty:run
http :8080/
http :8080/user.xml
http :8080/user.json