Thespring-greeter
quickstart is based on thegreeter
quickstart, but differs in that it uses Spring MVC for MappingGET
andPOST
requests.
The application this project produces is designed to be run on {productNameFull} {productVersion} or later.
The spring-greeter
quickstart is based on the greeter
quickstart, but differs in that it uses Spring MVC for Mapping GET
and POST
requests:
-
The
mvc:annotation-driven
element configured in thesrc/main/webapp/WEB-INF/spring-mvc-context.xml
file tells Spring to look for@RequestMapping
in the controllers. -
Spring then routes the HTTP requests to the correct methods in
CreateController.java
andGreetController
Spring’s XML configurations are used to get hold of the database and entity manager (via jndi) to perform transactional operations:
-
The
tx:jta-transaction-manager
andtx:annotation-driven
elements are configured in the/src/main/webapp/WEB-INF/spring-business-context.xml
file. -
Methods in UserDaoImpl are marked as
@Transactional
, which Spring, using aspect oriented programming, surrounds with boilerplate code to make the methods transactional
When you deploy this example, two users are automatically created for you: emuster and jdoe. This data is located in the
src/main/resources/init-db.sql
file.
To test this example:
-
Enter a name in the username field and click on Greet!.
-
If you enter a username that is not in the database, you get a message
No such user exists!`
. -
If you enter a valid username, you get a message "Hello, " followed by the user’s first and last name.
-
To create a new user, click the Add a new user link. Enter the username, first name, and last name, and then click Add User. The user is added and a message displays the new user ID number.
-
Click on the Greet a user! link to return to the Greet! page.
../shared-doc/system-requirements.adoc ../shared-doc/use-of-jboss-home-name.adoc ../shared-doc/start-the-standalone-server.adoc ../shared-doc/build-and-deploy-the-quickstart.adoc
If you do not have Maven configured you can manually copy target/spring-greeter.war
to {jbossHomeName}/standalone/deployments/
directory.
The application will be running at the following URL: http://localhost:8080/{artifactId}/
You will see the following warnings in the server log. You can ignore these warnings.
WARN [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0007: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
WARN [org.jboss.as.ee] (MSC service thread 1-5) WFLYEE0007: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
Or you can manually remove the application by removing {artifactId}.war
from the {jbossHomeName}/standalone/deployments/
directory.