Yet another spring-mvc demo project with better structure!
Java CSS HTML Vue JavaScript Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lotus.public update Jul 3, 2016


Build Status This project will allow you to start off on the good foot with spring MVC. In this showcase you'll see the following features in action:

  • Pure maven dependencies only spring, commons
  • Embedded Jetty
  • Mapping Requests
  • Message Converters
  • Message Source i18n support
  • Rendering Layout Views
  • Exception Handling
  • Multi environment packaging profiles

Get start

Clone the repository and modify the db config in classpath:conf/ then import the mysql script lotus.web/db.sql!


mvn -U clean install -DdownloadSources=true -Dmaven.test.skip=true
cd lotus.web && mvn jetty:run


Import the project as a maven project into your IDE, Run the class net.breakidea.web.Main then open


This is an application to demo the implementation of a REST API.

BTW: XML responses is not supported.

A better project structure is required:

  • lotus.web the webapp contains the portal project.
  • lotus.api api module,
  • lotus.public front page, based on webpack + Vue.
  • lotus.common config and application support, important config.

Use maven property named environment, conf to support dev , test and production environments, e.g:

mvn install -P production
  • default actived environment is dev
  • use environment as global runtime variable
  • conf the location of context:property-placeholder .properties file. see more
  • The messageSource (i18n) also includes property-placeholders

The Layout support. The velocity resource paths are:

  • /WEB-INF/views/ The primary template path
  • /WEB-INF/common/ velocity code snippets
  • {server.output}extends/ provides static external templates, Use oss:filename.html to include it.

Write your awesome template that assigned by the Controller in /WEB-INF/views/ folder.

Common modules such as header or footer locate in /WEB-INF/common/, then use context.render(name, data) to render it.

Templates that frequently modified will be managed by other service, then sync then to {server.output}extends/ folder~

For rendering context, the default attributes are:

  • application the WebApplicationContext instance
  • request the current HttpServletRequest
  • response the current HttpServletResponse
  • page the current context helper, net.breakidea.common.core.ContextHolder
  • context the context it's self
  • util tool, static class for

see @ContextHolder for detail


Lots of macros , such as block , extends , showContent , showInet , showMessage and so on. click here for details.

system [🏁]

Use maven profile to package diff environments. Between environments the only differences are property conf & environment .

Load the environment' property by ContextUtils.getEnv(key) that cached from file startWith system, e.g url.base, domain

  • global important config and messages in /WEB-INF/conf/.
  • application base url (with domain and / ) app.url.base e.g
  • load your .properties by net.breakidea.common.core.PropertiesLoader@loadProperties
  • CDN style resource app.url.assert e.g , see more at here
  • Project output path is system.output external templates can be put here.

This is the class that runs an embedded Jetty server with the servlet.

FreeBSD License