activation-1.1.jar
jodd-3.4.3.jar
jodd-joy-3.4.3.jar
logback-classic-1.0.0.jar
logback-core-1.0.0.jar
mysql-connector-java-5.1.12-bin.jar
simplecaptcha-1.1.1.jar
slf4j-api-1.7.2.jar
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<!-- context -->
<listener>
<listener-class>jodd.madvoc.MadvocContextListener</listener-class>
</listener>
<context-param>
<param-name>madvoc.webapp</param-name>
<param-value>com.quickstart.core.AppWebApplication</param-value>
</context-param>
<context-param>
<param-name>madvoc.params</param-name>
<param-value>/madvoc.props</param-value>
</context-param>
<!--listeners-->
<listener>
<listener-class>jodd.servlet.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>jodd.servlet.HttpSessionListenerBroadcaster</listener-class>
</listener>
<!-- remove session from url -->
<filter>
<filter-name>RemoveSessionFromUrl</filter-name>
<filter-class>jodd.servlet.filter.RemoveSessionFromUrlFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RemoveSessionFromUrl</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- gzip -->
<filter>
<filter-name>gzip</filter-name>
<filter-class>jodd.servlet.filter.GzipFilter</filter-class>
<init-param>
<param-name>threshold</param-name>
<param-value>128</param-value>
</init-param>
<init-param>
<param-name>match</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>exclude</param-name>
<param-value>/jodd-bundle</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>gzip</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
<!-- html stapler-->
<filter>
<filter-name>html-stapler</filter-name>
<filter-class>jodd.htmlstapler.HtmlStaplerFilter</filter-class>
<init-param>
<param-name>useGzip</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>html-stapler</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- decora -->
<filter>
<filter-name>decora</filter-name>
<filter-class>jodd.decora.DecoraServletFilter</filter-class>
<init-param>
<param-name>decora.manager</param-name>
<param-value>com.quickstart.core.AppDecoraManager</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>decora</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- madvoc -->
<filter>
<filter-name>madvoc</filter-name>
<filter-class>jodd.madvoc.MadvocServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>madvoc</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<!--<dispatcher>INCLUDE</dispatcher>-->
<!--<dispatcher>FORWARD</dispatcher>-->
</filter-mapping>
<!-- servlet -->
<servlet>
<servlet-name>StickyCaptcha</servlet-name>
<servlet-class>nl.captcha.servlet.StickyCaptchaServlet</servlet-class>
<init-param>
<param-name>width</param-name>
<param-value>250</param-value>
</init-param>
<init-param>
<param-name>height</param-name>
<param-value>100</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>StickyCaptcha</servlet-name>
<url-pattern>/stickyImg</url-pattern>
</servlet-mapping>
<!-- configuration -->
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
<include-prelude>/jspf/prelude.jspf</include-prelude>
<include-coda>/jspf/coda.jspf</include-coda>
</jsp-property-group>
</jsp-config>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/error.404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.500.jsp</location>
</error-page>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
# list of madvoc method action annotation
madvocConfig.actionAnnotations=\
jodd.madvoc.meta.Action,\
jodd.joy.madvoc.meta.PostAction,\
jodd.joy.madvoc.meta.JSONAction,\
com.quickstart.core.meta.PopupAction
# list of default interceptors
madvocConfig.defaultInterceptors=com.quickstart.core.interceptor.AppInterceptorStack
# unlimited uploads size
madvocConfig.fileUploadFactory.maxFileSize=-1
# empty parameters will not be ignored (default)
madvocConfig.requestScopeInjectorConfig.ignoreEmptyRequestParams=false
# empty parameters will be threaded as nulls
madvocConfig.requestScopeInjectorConfig.treatEmptyParamsAsNull=true
# create default aliases for all actions
madvocConfig.createDefaultAliases=true
# in production we can disable it
jodd.madvoc.interceptor.EchoInterceptor.enabled=true
# debug mode for database
db.debug=true
# database data
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/数据库名?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true
jdbc.username=用户名
jdbc.password=密码
# database pool
dbpool.driver=${jdbc.driverClassName}
dbpool.url=${jdbc.url}
dbpool.user=${jdbc.username}
dbpool.password=${jdbc.password}
dbpool.maxConnections=10
dbpool.minConnections=5
dbpool.waitIfBusy=true
dbpool.validateConnection=true
dbpool.validationQuery=select 1
# db orm manager
dboom.tableNames.prefix=sys_
dboom.tableNames.uppercase=false
dboom.columnNames.uppercase=false
dboom.schemaName=jodd
# example how column alias type
# can be set for all queries
#dboom.defaultColumnAliasType=COLUMN_CODE
# example how to turn on ID generation using Jodd
#appDao.generatedKeys=false
#jodd.joy.db.AppDao.generatedKeys=${appDao.generatedKeys}
Model
/**
* User model object.
*/
@DbTable
public class User extends DbEntity {
@DbColumn
private String username;
@DbColumn
private String password;
@DbColumn("roleName")
private String roleName;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
}
Service
@PetiteBean
public class UserService {
@PetiteInject
AppDao appDao;
public List<User> findAllUsers() {
DbOomQuery query = query(sql("select $C{user.*} from $T{User user}"));
return query.list(User.class);
}
}
Action
@MadvocAction
public class UserAction extends AppAction{
@PetiteInject
UserService userService;
@Out
List<User> users;
/**
* Mapped to /index.html page. Calls a service.
*/
@Action
@Transaction
public void findAll() {
users = userService.findAllUsers();
}
}
例子下载:http://vdisk.weibo.com/s/E7Uwy