日系框架之seasar2(S2JSF)

回想起当年使用struts的时候,对他的tag真是又爱又恨。盼星星盼月亮,迎来了JSF。

然而,JSF的tag库虽然强大,却失去了灵活性,反而让人望而生畏。

S2JSF在通过seasar2的DI功能,把JSF标签注入到HTML页面,实现了类似模板引擎的功能。

示例如下:

如下图所示新建工程:

日系框架之seasar2(S2JSF)_第1张图片

日系框架之seasar2(S2JSF)_第2张图片

代码依次为:

AddAction.java
  1. package examples.jsf.action;
  2. public interface AddAction {
  3.     public String calculate();
  4. }

AddActionImpl.java

  1. package examples.jsf.action.impl;
  2. import examples.jsf.action.AddAction;
  3. import examples.jsf.dto.AddDto;
  4. import examples.jsf.logic.AddLogic;
  5. public class AddActionImpl implements AddAction {
  6.     private AddDto addDto;
  7.     private AddLogic addLogic;
  8.     public void setAddDto(AddDto addDto) {
  9.         this.addDto = addDto;
  10.     }
  11.     public void setAddLogic(AddLogic addLogic) {
  12.         this.addLogic = addLogic;
  13.     }
  14.     public String calculate() {
  15.         int result = addLogic.calculate(addDto);
  16.         addDto.setResult(result);
  17.         return null;
  18.     }
  19. }

allaop.dicon

  1. <?xml version="1.0" encoding="Shift_JIS"?>
  2. <!DOCTYPE components PUBLIC "-//SEASAR2.1//DTD S2Container//EN"
  3.     "http://www.seasar.org/dtd/components21.dtd">
  4. <components>
  5.     <include path="aop.dicon"/>
  6.     <include path="dao.dicon"/>
  7.     <include path="j2ee.dicon"/>
  8.     <component
  9.         name="actionThrowsInterceptor"
  10.         class="examples.jsf.interceptor.ActionThrowsInterceptor"
  11.     />
  12.     <component
  13.         name="actionInterceptorChain"
  14.         class="org.seasar.framework.aop.interceptors.InterceptorChain"
  15.     >
  16.         <initMethod name="add"><arg>aop.traceInterceptor</arg></initMethod>
  17.         <initMethod name="add"><arg>actionThrowsInterceptor</arg></initMethod>
  18.     </component>
  19.     <component
  20.         name="logicInterceptorChain"
  21.         class="org.seasar.framework.aop.interceptors.InterceptorChain"
  22.     >
  23.         <initMethod name="add"><arg>aop.traceThrowsInterceptor</arg></initMethod>
  24.         <initMethod name="add"><arg>aop.traceInterceptor</arg></initMethod>
  25.         <initMethod name="add"><arg>j2ee.requiredTx</arg></initMethod>
  26.     </component>
  27.     <component
  28.         name="daoInterceptorChain"
  29.         class="org.seasar.framework.aop.interceptors.InterceptorChain"
  30.     >
  31.         <initMethod name="add"><arg>aop.traceInterceptor</arg></initMethod>
  32.         <initMethod name="add"><arg>dao.interceptor</arg></initMethod>
  33.     </component>
  34. </components>

AddDto.java

  1. package examples.jsf.dto;
  2. import java.io.Serializable;
  3. public class AddDto implements Serializable {
  4.     private static final long serialVersionUID = 1L;
  5.     private int arg1;
  6.     private int arg2;
  7.     private int result;
  8.     public AddDto() {
  9.     }
  10.     public int getArg1() {
  11.         return arg1;
  12.     }
  13.     public void setArg1(int arg1) {
  14.         this.arg1 = arg1;
  15.     }
  16.     public int getArg2() {
  17.         return arg2;
  18.     }
  19.     public void setArg2(int arg2) {
  20.         this.arg2 = arg2;
  21.     }
  22.     public int getResult() {
  23.         return result;
  24.     }
  25.     public void setResult(int result) {
  26.         this.result = result;
  27.     }
  28. }

HelloDto.java

  1. package examples.jsf.dto;
  2. public class HelloDto {
  3.     private String name = "S2JSF";
  4.     public String getName() {
  5.         return name;
  6.     }
  7.     public void setName(String name) {
  8.         this.name = name;
  9.     }
  10. }

AppRuntimeException.java

  1. package examples.jsf.exception;
  2. import java.text.MessageFormat;
  3. import java.util.ResourceBundle;
  4. public class AppRuntimeException extends RuntimeException {
  5.     private static final long serialVersionUID = 1L;
  6.     private static final Object[] EMPTY_ARGS = new Object[0];
  7.     private static final String BUNDLE_NAME = "appMessages";
  8.     
  9.     private String messageId;
  10.     
  11.     private Object[] args;
  12.     
  13.     public AppRuntimeException(String messageId) {
  14.         this(messageId, EMPTY_ARGS);
  15.     }
  16.     public AppRuntimeException(String messageId, Object[] args) {
  17.         this(messageId, args, null);
  18.     }
  19.     public AppRuntimeException(String messageId, Object[] args, Throwable cause) {
  20.         initCause(cause);
  21.         this.messageId = messageId;
  22.         this.args = args;
  23.     }
  24.     
  25.     public Object[] getArgs() {
  26.         return args;
  27.     }
  28.     
  29.     public String getMessageId() {
  30.         return messageId;
  31.     }
  32.     
  33.     public String getMessage() {
  34.         ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME);
  35.         String pattern = bundle.getString(messageId);
  36.         return MessageFormat.format(pattern, args);
  37.     }
  38. }

ActionThrowsInterceptor.java

  1. package examples.jsf.interceptor;
  2. import javax.faces.context.FacesContext;
  3. import org.aopalliance.intercept.MethodInvocation;
  4. import org.seasar.framework.aop.interceptors.ThrowsInterceptor;
  5. import org.seasar.jsf.util.MessageUtil;
  6. import examples.jsf.exception.AppRuntimeException;
  7. public class ActionThrowsInterceptor extends ThrowsInterceptor {
  8.     
  9.     private static final long serialVersionUID = 1L;
  10.     public String handleThrowable(AppRuntimeException ex, MethodInvocation invocation) throws Throwable {
  11.         FacesContext context = FacesContext.getCurrentInstance();
  12.         context.addMessage(null, MessageUtil.getErrorMessage(ex.getMessageId(), ex.getArgs()));
  13.         return null;
  14.     }
  15. }

AddLogic.java

  1. package examples.jsf.logic;
  2. import examples.jsf.dto.AddDto;
  3. public interface AddLogic {
  4.     public int calculate(AddDto addDto);
  5. }

AddLogicImpl.java

  1. package examples.jsf.logic.impl;
  2. import examples.jsf.dto.AddDto;
  3. import examples.jsf.logic.AddLogic;
  4. public class AddLogicImpl implements AddLogic {
  5.     public AddLogicImpl() {
  6.     }
  7.     public int calculate(AddDto addDto) {
  8.         return addDto.getArg1() + addDto.getArg2();
  9.     }
  10. }

RequestDumpFilter.java

  1. package examples.jsf.util;
  2. import java.io.IOException;
  3. import javax.servlet.Filter;
  4. import javax.servlet.FilterChain;
  5. import javax.servlet.FilterConfig;
  6. import javax.servlet.ServletContext;
  7. import javax.servlet.ServletException;
  8. import javax.servlet.ServletRequest;
  9. import javax.servlet.ServletResponse;
  10. import javax.servlet.http.HttpServletRequest;
  11. import org.apache.commons.logging.Log;
  12. import org.apache.commons.logging.LogFactory;
  13. public final class RequestDumpFilter implements Filter {
  14.     private static final Log log = LogFactory.getLog(RequestDumpFilter.class);
  15.     private FilterConfig config = null;
  16.     public void init(final FilterConfig filterConfig) throws ServletException {
  17.         config = filterConfig;
  18.     }
  19.     public void destroy() {
  20.         config = null;
  21.     }
  22.     private static final String INDENT = "  ";
  23.     private static final String LF = System.getProperty("line.separator");
  24.     public void doFilter(final ServletRequest request,
  25.             final ServletResponse response, final FilterChain chain)
  26.             throws IOException, ServletException {
  27.         if (config == null) {
  28.             return;
  29.         }
  30.         if (request instanceof HttpServletRequest) {
  31.             final HttpServletRequest hrequest = (HttpServletRequest) request;
  32.             log.debug(LF + LF
  33.                     + "** before *****************************************: "
  34.                     + gerServletPath(request) + LF + dumpRequest(hrequest));
  35.             try {
  36.                 chain.doFilter(request, response);
  37.             } finally {
  38.                 final StringBuffer sb = new StringBuffer();
  39.                 RequestDumpUtil.dumpRequestAttributes(sb, hrequest, LF, INDENT);
  40.                 RequestDumpUtil.dumpCookies(sb, hrequest, LF, INDENT);
  41.                 RequestDumpUtil.dumpSessionAttributes(sb, hrequest, LF, INDENT);
  42.                 RequestDumpUtil.dumpContextAttributes(sb, config
  43.                         .getServletContext(), LF, INDENT);
  44.                 log
  45.                         .debug(LF
  46.                                 + LF
  47.                                 + "** after *****************************************: "
  48.                                 + gerServletPath(request) + LF + sb.toString());
  49.             }
  50.         } else {
  51.             chain.doFilter(request, response);
  52.         }
  53.     }
  54.     private String dumpRequest(final HttpServletRequest request) {
  55.         final StringBuffer sb = new StringBuffer();
  56.         final ServletContext context = config.getServletContext();
  57.         RequestDumpUtil.dumpRequestAndContextProperties(sb, request, context,
  58.                 LF, INDENT);
  59.         RequestDumpUtil.dumpRequestParameters(sb, request, LF, INDENT);
  60.         RequestDumpUtil.dumpRequestAttributes(sb, request, LF, INDENT);
  61.         RequestDumpUtil.dumpCookies(sb, request, LF, INDENT);
  62.         RequestDumpUtil.dumpRequestHeaders(sb, request, LF, INDENT);
  63.         RequestDumpUtil.dumpSessionAttributes(sb, request, LF, INDENT);
  64.         RequestDumpUtil.dumpContextAttributes(sb, context, LF, INDENT);
  65.         return sb.toString();
  66.     }
  67.     private String gerServletPath(final ServletRequest request) {
  68.         if (request instanceof HttpServletRequest) {
  69.             return ((HttpServletRequest) request).getServletPath();
  70.         }
  71.         return null;
  72.     }
  73.     public String toString() {
  74.         if (config == null) {
  75.             return ("RequestDumperFilter()");
  76.         }
  77.         final StringBuffer sb = new StringBuffer("RequestDumperFilter(");
  78.         sb.append(config);
  79.         sb.append(")");
  80.         return (sb.toString());
  81.     }
  82. }

RequestDumpUtil.java

  1. package examples.jsf.util;
  2. import java.util.Collections;
  3. import java.util.Enumeration;
  4. import java.util.Iterator;
  5. import java.util.Locale;
  6. import java.util.SortedSet;
  7. import java.util.TreeSet;
  8. import javax.servlet.ServletContext;
  9. import javax.servlet.http.Cookie;
  10. import javax.servlet.http.HttpServletRequest;
  11. import javax.servlet.http.HttpSession;
  12. public class RequestDumpUtil {
  13.     public static void dumpRequestHeaders(final StringBuffer sb,
  14.             final HttpServletRequest request, final String lf,
  15.             final String indent) {
  16.         for (final Iterator it = toSortedSet(request.getHeaderNames())
  17.                 .iterator(); it.hasNext();) {
  18.             final String name = (String) it.next();
  19.             final String value = request.getHeader(name);
  20.             sb.append(indent);
  21.             sb.append("[header]").append(name);
  22.             sb.append("=").append(value);
  23.             sb.append(lf);
  24.         }
  25.     }
  26.     public static void dumpContextAttributes(final StringBuffer sb,
  27.             final ServletContext servletContext, final String lf,
  28.             final String indent) {
  29.         if (servletContext == null) {
  30.             return;
  31.         }
  32.         for (final Iterator it = toSortedSet(servletContext.getAttributeNames())
  33.                 .iterator(); it.hasNext();) {
  34.             final String name = (String) it.next();
  35.             final Object attr = servletContext.getAttribute(name);
  36.             sb.append(indent);
  37.             sb.append("[context]").append(name).append("=").append(attr);
  38.             sb.append(lf);
  39.         }
  40.     }
  41.     public static void dumpCookies(final StringBuffer sb,
  42.             final HttpServletRequest request, final String lf,
  43.             final String indent) {
  44.         Cookie cookies[] = request.getCookies();
  45.         if (cookies == null) {
  46.             cookies = new Cookie[0];
  47.         }
  48.         for (int i = 0; i < cookies.length; i++) {
  49.             sb.append(indent);
  50.             sb.append("[cookie]").append(cookies[i].getName());
  51.             sb.append("=").append(cookies[i].getValue());
  52.             sb.append(lf);
  53.         }
  54.     }
  55.     public static void dumpRequestAttributes(final StringBuffer sb,
  56.             final HttpServletRequest request, final String lf,
  57.             final String indent) {
  58.         for (final Iterator it = toSortedSet(request.getAttributeNames())
  59.                 .iterator(); it.hasNext();) {
  60.             final String name = (String) it.next();
  61.             final Object attr = request.getAttribute(name);
  62.             sb.append(indent);
  63.             sb.append("[request]").append(name).append("=").append(attr);
  64.             sb.append(lf);
  65.         }
  66.     }
  67.     public static void dumpSessionAttributes(final StringBuffer sb,
  68.             final HttpServletRequest request, final String lf,
  69.             final String indent) {
  70.         final HttpSession session = request.getSession(false);
  71.         if (session == null) {
  72.             return;
  73.         }
  74.         for (final Iterator it = toSortedSet(session.getAttributeNames())
  75.                 .iterator(); it.hasNext();) {
  76.             final String name = (String) it.next();
  77.             final Object attr = session.getAttribute(name);
  78.             sb.append(indent);
  79.             sb.append("[session]").append(name).append("=").append(attr);
  80.             sb.append(lf);
  81.         }
  82.     }
  83.     private static SortedSet toSortedSet(final Enumeration enu) {
  84.         final SortedSet set = new TreeSet();
  85.         set.addAll(Collections.list(enu));
  86.         return set;
  87.     }
  88.     public static void dumpRequestParameters(final StringBuffer sb,
  89.             final HttpServletRequest request, final String lf,
  90.             final String indent) {
  91.         for (final Iterator it = toSortedSet(request.getParameterNames())
  92.                 .iterator(); it.hasNext();) {
  93.             final String name = (String) it.next();
  94.             sb.append(indent);
  95.             sb.append("[param]").append(name).append("=");
  96.             final String values[] = request.getParameterValues(name);
  97.             for (int i = 0; i < values.length; i++) {
  98.                 if (i > 0) {
  99.                     sb.append(", ");
  100.                 }
  101.                 sb.append(values[i]);
  102.             }
  103.             sb.append(lf);
  104.         }
  105.     }
  106.     public static void dumpRequestAndContextProperties(final StringBuffer sb,
  107.             final HttpServletRequest request, final ServletContext context,
  108.             final String lf, final String indent) {
  109.         final HttpSession session = request.getSession(false);
  110.         sb.append(indent);
  111.         sb.append("Request class=" + request.getClass().getName()).append(
  112.                 ", instance=").append(request);
  113.         sb.append(lf);
  114.         sb.append(indent);
  115.         sb.append("RequestedSessionId=")
  116.                 .append(request.getRequestedSessionId());
  117.         sb.append(lf);
  118.         sb.append(indent);
  119.         if (session != null) {
  120.             sb.append(" Session SessionId=").append(session.getId());
  121.             sb.append(lf).append(indent);
  122.         }
  123.         sb.append("REQUEST_URI=").append(request.getRequestURI());
  124.         sb.append(", SERVLET_PATH=").append(request.getServletPath());
  125.         sb.append(lf).append(indent);
  126.         if (session != null) {
  127.             sb.append("Session :: CreationTime=").append(
  128.                     session.getCreationTime());
  129.             sb.append(", LastAccessedTime=").append(
  130.                     session.getLastAccessedTime());
  131.             sb.append(", MaxInactiveInterval=").append(
  132.                     session.getMaxInactiveInterval());
  133.             sb.append(lf).append(indent);
  134.         }
  135.         sb.append("CharacterEncoding=" + request.getCharacterEncoding());
  136.         sb.append(", ContentLength=").append(request.getContentLength());
  137.         sb.append(", ContentType=").append(request.getContentType());
  138.         sb.append(", Locale=").append(request.getLocale());
  139.         sb.append(", Locales=");
  140.         final Enumeration locales = request.getLocales();
  141.         boolean first = true;
  142.         while (locales.hasMoreElements()) {
  143.             final Locale locale = (Locale) locales.nextElement();
  144.             if (first) {
  145.                 first = false;
  146.             } else {
  147.                 sb.append(", ");
  148.             }
  149.             sb.append(locale.toString());
  150.         }
  151.         sb.append(", Scheme=").append(request.getScheme());
  152.         sb.append(", isSecure=").append(request.isSecure());
  153.         sb.append(lf).append(indent);
  154.         sb.append("SERVER_PROTOCOL=").append(request.getProtocol());
  155.         sb.append(", REMOTE_ADDR=").append(request.getRemoteAddr());
  156.         sb.append(", REMOTE_HOST=").append(request.getRemoteHost());
  157.         sb.append(", SERVER_NAME=").append(request.getServerName());
  158.         sb.append(", SERVER_PORT=").append(request.getServerPort());
  159.         sb.append(lf);
  160.         sb.append(indent);
  161.         sb.append("ContextRealPath=").append(context.getRealPath("/"));
  162.         sb.append(lf).append(indent);
  163.         sb.append("SERVER_SOFTWARE=").append(context.getServerInfo());
  164.         sb.append(", ServletContextName=").append(
  165.                 context.getServletContextName());
  166.         sb.append(", MajorVersion=").append(context.getMajorVersion());
  167.         sb.append(", MinorVersion=").append(context.getMinorVersion());
  168.         sb.append(lf).append(indent);
  169.         sb.append("ContextPath=").append(request.getContextPath());
  170.         sb.append(", REQUEST_METHOD=").append(request.getMethod());
  171.         sb.append(", QUERY_STRING=").append(request.getQueryString());
  172.         sb.append(", PathInfo=").append(request.getPathInfo());
  173.         sb.append(", RemoteUser=").append(request.getRemoteUser());
  174.         sb.append(lf);
  175.     }
  176. }

app.dicon

  1. <?xml version="1.0" encoding="Shift_JIS"?>
  2. <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
  3.     "http://www.seasar.org/dtd/components24.dtd">
  4. <components>
  5.     <include path="jsf.dicon"/>
  6.     <include path="teeda.dicon"/>
  7.     <include path="dao.dicon"/>
  8.     <include path="examples/jsf/dicon/allaop.dicon"/>
  9.     <component
  10.         class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister"
  11.     >
  12.         <property name="instanceDef">
  13.             @org.seasar.framework.container.deployer.InstanceDefFactory@REQUEST
  14.         </property>
  15.         <initMethod name="addClassPattern">
  16.             <arg>"examples.jsf.action.impl"</arg>
  17.             <arg>".*ActionImpl"</arg>
  18.         </initMethod>
  19.     </component>
  20.     <component
  21.         class="org.seasar.framework.container.autoregister.AspectAutoRegister"
  22.     >
  23.         <property name="interceptor">actionInterceptorChain</property>
  24.         <initMethod name="addClassPattern">
  25.             <arg>"examples.jsf.action.impl"</arg>
  26.             <arg>".*ActionImpl"</arg>
  27.         </initMethod>
  28.     </component>
  29.     <component
  30.         class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister"
  31.     >
  32.         <property name="instanceDef">
  33.             @org.seasar.framework.container.deployer.InstanceDefFactory@REQUEST
  34.         </property>
  35.         <initMethod name="addClassPattern">
  36.             <arg>"examples.jsf.dto"</arg>
  37.             <arg>".*Dto"</arg>
  38.         </initMethod>
  39.     </component>
  40.     <component
  41.         class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister"
  42.     >
  43.         <initMethod name="addClassPattern">
  44.             <arg>"examples.jsf.logic.impl"</arg>
  45.             <arg>".*LogicImpl"</arg>
  46.         </initMethod>
  47.     </component>
  48.     <component
  49.         class="org.seasar.framework.container.autoregister.AspectAutoRegister"
  50.     >
  51.         <property name="interceptor">logicInterceptorChain</property>
  52.         <initMethod name="addClassPattern">
  53.             <arg>"examples.jsf.logic.impl"</arg>
  54.             <arg>".*LogicImpl"</arg>
  55.         </initMethod>
  56.     </component>
  57. </components>

appMessages.properties和appMessages_ja.properties暂为空。

convention.dicon

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
  3.     "http://www.seasar.org/dtd/components24.dtd">
  4. <components>
  5.     <component class="org.seasar.framework.convention.impl.NamingConventionImpl"/>
  6. </components>

jdbc.dicon(本例中未使用数据库,可按实际情况更改配置)

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
  3.     "http://www.seasar.org/dtd/components24.dtd">
  4. <components namespace="jdbc">
  5.     <include path="jta.dicon"/>
  6.     <include path="jdbc-extension.dicon"/>
  7.     
  8.     <component class="org.seasar.extension.jdbc.impl.BasicResultSetFactory"/>
  9.     <component class="org.seasar.extension.jdbc.impl.ConfigurableStatementFactory">
  10.         <arg>
  11.             <component class="org.seasar.extension.jdbc.impl.BasicStatementFactory"/>
  12.         </arg>
  13.         <property name="fetchSize">100</property>
  14.         <!--
  15.         <property name="maxRows">100</property>
  16.         -->
  17.     </component>
  18.     <!--
  19.     <component class="org.seasar.extension.jdbc.impl.OracleResultSetFactory"/>
  20.     <component class="org.seasar.extension.jdbc.impl.BooleanToIntStatementFactory"/>
  21.     -->
  22.     <!-- for HSQLDB -->
  23.     <component name="xaDataSource"
  24.         class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
  25.         <property name="driverClassName">
  26.             "org.hsqldb.jdbcDriver"
  27.         </property>
  28.         <property name="URL">
  29.             "jdbc:hsqldb:hsql://localhost:9001"
  30.             <!--
  31.             "jdbc:hsqldb:file:"
  32.                 + @org.seasar.framework.util.ResourceUtil@getBuildDir(@org.seasar.extension.dbcp.impl.ConnectionPoolImplTest@class).getCanonicalPath()
  33.                 + "/data/demo"
  34.             -->
  35.         </property>
  36.         <property name="user">"sa"</property>
  37.         <property name="password">""</property>
  38.     </component>
  39.     <!-- for Oracle -->
  40.     <!--
  41.     <component name="xaDataSource"
  42.         class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
  43.         <property name="driverClassName">
  44.             "oracle.jdbc.driver.OracleDriver"
  45.         </property>
  46.         <property name="URL">
  47.             "jdbc:oracle:thin:@xxx:1521:xxx"
  48.         </property>
  49.         <property name="user">"xxx"</property>
  50.         <property name="password">"xxx"</property>
  51.     </component>
  52.     -->
  53.     <!-- for PostgreSQL -->
  54.     <!--
  55.     <component name="xaDataSource"
  56.         class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
  57.         <property name="driverClassName">
  58.             "org.postgresql.Driver"
  59.         </property>
  60.         <property name="URL">
  61.           "jdbc:postgresql://localhost/TEST"
  62.         </property>
  63.         <property name="user">"xxxx"</property>
  64.         <property name="password">"xxxx"</property>
  65.     </component>
  66.     -->
  67.     <!-- MySQL
  68.     - MySQL4.0以下でマルチバイト文字を扱う場合には,URL指定の後に,
  69.         以下の接続パラメータを追加で指定してください.
  70.         useUnicode=true
  71.         characterEncoding=[MySQLのエンコーディングに対応した
  72.         Javaのエンコーディング名]
  73.         例:"jdbc:mysql://localhost:3306/test?useUnicode=true" +
  74.         "&characterEncoding=Windows-31J"
  75.     - MySQL5.0以降で,エンコーディングがeucjpmsの列を扱う場合には,
  76.         URL指定の後に,以下の接続パラメータを追加で指定してください.
  77.         characterEncoding=UTF-8またはWindows-31J
  78.         characterSetResults=UTF-8またはWindows-31J
  79.         例:"jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8" +
  80.         "&characterSetResults=UTF-8"
  81.         この指定をしない場合,Java側でUCS-2⇔EUC_JP_Solarisの変換が
  82.         行なわれるため,ユーザー定義外字などの一部の文字が化けます.
  83.         この指定をすることで,MySQL側でeucjpms⇔ucs2⇔utf8(cp932)の
  84.         変換が行なわれ,Java側でUCS-2⇔UTF-8(Windows-31J)の変換が
  85.         行なわれるようになります.この結果,文字化けを防げます.
  86.         なおJIS X 0212(補助漢字)を使用する場合は,Windows-31Jではなく
  87.         UTF-8を指定する必要があります.
  88.     - 上記以外の場合は,my.cnfでdefault-character-setの設定を適切に
  89.         (cp932やutf8など.デフォルトのlatin1は不可)行なっていれば,
  90.         文字化けは防げます.
  91.     <component name="xaDataSource"
  92.         class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
  93.         <property name="driverClassName">
  94.             "com.mysql.jdbc.Driver"
  95.         </property>
  96.         <property name="URL">
  97.             "jdbc:mysql://localhost:3306/test"
  98.         </property>
  99.         <property name="user">"xxx"</property>
  100.         <property name="password">"xxx"</property>
  101.     </component>
  102.     -->
  103.     <!-- for SQLServer -->
  104.     <!--
  105.     <component name="xaDataSource"
  106.         class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
  107.         <property name="driverClassName">
  108.             "net.sourceforge.jtds.jdbc.Driver"
  109.         </property>
  110.         <property name="URL">
  111.             "jdbc:jtds:sqlserver://localhost/TEST;instance=SQLEXPRESS"
  112.         </property>
  113.         <property name="user">"xxxx"</property>
  114.         <property name="password">"xxxx"</property>
  115.     </component>
  116.     -->
  117.     <component name="connectionPool"
  118.         class="org.seasar.extension.dbcp.impl.ConnectionPoolImpl">
  119.         <property name="timeout">600</property>
  120.         <property name="maxPoolSize">10</property>
  121.         <property name="allowLocalTx">true</property>
  122.         <destroyMethod name="close"/>
  123.     </component>
  124.     <component name="DataSource"
  125.         class="org.seasar.extension.dbcp.impl.DataSourceImpl"
  126.     />
  127.     <!-- from JNDI -->
  128.     <!--
  129.     <component name="DataSource"
  130.         class="javax.sql.DataSource">
  131.         @org.seasar.extension.j2ee.JndiResourceLocator@lookup("java:comp/env/jdbc/DataSource")
  132.     </component>
  133.     -->
  134. </components>

jsf.dicon

  1. <?xml version="1.0" encoding="Shift_JIS"?>
  2. <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
  3.     "http://www.seasar.org/dtd/components24.dtd">
  4. <components namespace="jsf" >
  5.     <include path="jsfErrorPage.dicon"/>
  6.     <component class="org.seasar.jsf.runtime.CompositeTaglibManager">
  7.         <initMethod name="addTaglibManager">
  8.             <arg>
  9.                 <component class="org.seasar.jsf.runtime.FileSystemTaglibManagerImpl">
  10.                     <initMethod name="init"/>
  11.                     <destroyMethod name="destroy"/>
  12.                 </component>
  13.             </arg>
  14.         </initMethod>
  15.         <initMethod name="addTaglibManager">
  16.             <arg>
  17.                 <component class="org.seasar.jsf.runtime.ServletContextTaglibManagerImpl">
  18.                     <initMethod name="init"/>
  19.                     <destroyMethod name="destroy"/>
  20.                 </component>
  21.             </arg>
  22.         </initMethod>
  23.     </component>
  24.     <component class="org.seasar.jsf.runtime.JsfConfigImpl">
  25.         <initMethod name="addTaglibUri">
  26.             <arg>"h"</arg>
  27.             <arg>"http://java.sun.com/jsf/html"</arg>
  28.         </initMethod>
  29.         <initMethod name="addTaglibUri">
  30.             <arg>"f"</arg>
  31.             <arg>"http://java.sun.com/jsf/core"</arg>
  32.         </initMethod>
  33.         <initMethod name="addTaglibUri">
  34.             <arg>"s"</arg>
  35.             <arg>"http://www.seasar.org/jsf"</arg>
  36.         </initMethod>
  37.         <initMethod name="addTaglibUri">
  38.             <arg>"x"</arg>
  39.             <arg>"http://myfaces.apache.org/tomahawk"</arg>
  40.         </initMethod>   
  41.         <initMethod name="addTaglibUri">
  42.             <arg>"hello"</arg>
  43.             <arg>"http://examples.jsf/taglib"</arg>
  44.         </initMethod>   
  45.         <initMethod name="addTaglibUri">
  46.             <arg>"r"</arg>
  47.             <arg>"http://examples.jsf.hoge/taglib"</arg>
  48.         </initMethod>   
  49.     </component>
  50.     
  51.     <component class="org.seasar.jsf.runtime.TagPoolImpl"/>
  52.     
  53.     <component class="org.seasar.jsf.runtime.TagProcessorTreeFactoryImpl">
  54.         <initMethod name="addTagSelector">
  55.             <arg>
  56.                 <component class="org.seasar.jsf.selector.PassThroughElementSelector"/>
  57.             </arg>
  58.         </initMethod>
  59.         <initMethod name="addTagSelector">
  60.             <arg>
  61.                 <component class="org.seasar.jsf.selector.SelectManyCheckboxSelector"/>
  62.             </arg>
  63.         </initMethod>
  64.         <initMethod name="addTagSelector">
  65.             <arg>
  66.                 <component class="org.seasar.jsf.selector.SelectOneRadioSelector"/>
  67.             </arg>
  68.         </initMethod>
  69.         <initMethod name="addTagSelector">
  70.             <arg>
  71.                 <component class="org.seasar.jsf.selector.SelectItemSelector"/>
  72.             </arg>
  73.         </initMethod>
  74.         <initMethod name="addTagSelector">
  75.             <arg>
  76.                 <component class="org.seasar.jsf.selector.InsertSelector"/>
  77.             </arg>
  78.         </initMethod>
  79.         <initMethod name="addTagSelector">
  80.             <arg>
  81.                 <component class="org.seasar.jsf.selector.ValidatorSelector"/>
  82.             </arg>
  83.         </initMethod>
  84.         <initMethod name="addTagSelector">
  85.             <arg>
  86.                 <component class="org.seasar.jsf.selector.InjectSelector"/>
  87.             </arg>
  88.         </initMethod>
  89.         <initMethod name="addTagSelector">
  90.             <arg>
  91.                 <component class="org.seasar.jsf.selector.MetaContentTypeSelector"/>
  92.             </arg>
  93.         </initMethod>
  94.         <initMethod name="addTagSelector">
  95.             <arg>
  96.                 <component class="org.seasar.jsf.selector.HtmlSelector"/>
  97.             </arg>
  98.         </initMethod>
  99.         <initMethod name="addTagSelector">
  100.             <arg>
  101.                 <component class="org.seasar.jsf.selector.OutputTextSelector"/>
  102.             </arg>
  103.         </initMethod>
  104.         <initMethod name="addTagSelector">
  105.             <arg>
  106.                 <component class="org.seasar.jsf.selector.TitleSelector"/>
  107.             </arg>
  108.         </initMethod>
  109.         <initMethod name="addTagSelector">
  110.             <arg>
  111.                 <component class="org.seasar.jsf.selector.OutputLinkSelector"/>
  112.             </arg>
  113.         </initMethod>
  114.         <initMethod name="addTagSelector">
  115.             <arg>
  116.                 <component class="org.seasar.jsf.selector.CommandButtonSelector"/>
  117.             </arg>
  118.         </initMethod>
  119.         <initMethod name="addTagSelector">
  120.             <arg>
  121.                 <component class="org.seasar.jsf.selector.CommandLinkSelector"/>
  122.             </arg>
  123.         </initMethod>
  124.         <initMethod name="addTagSelector">
  125.             <arg>
  126.                 <component class="org.seasar.jsf.selector.FormSelector"/>
  127.             </arg>
  128.         </initMethod>
  129.         <initMethod name="addTagSelector">
  130.             <arg>
  131.                 <component class="org.seasar.jsf.selector.BaseSelector"/>
  132.             </arg>
  133.         </initMethod>
  134.         <initMethod name="addTagSelector">
  135.             <arg>
  136.                 <component class="org.seasar.jsf.selector.InputTextSelector"/>
  137.             </arg>
  138.         </initMethod>
  139.         <initMethod name="addTagSelector">
  140.             <arg>
  141.                 <component class="org.seasar.jsf.selector.InputHiddenSelector"/>
  142.             </arg>
  143.         </initMethod>
  144.         <initMethod name="addTagSelector">
  145.             <arg>
  146.                 <component class="org.seasar.jsf.selector.InputSecretSelector"/>
  147.             </arg>
  148.         </initMethod>
  149.         <initMethod name="addTagSelector">
  150.             <arg>
  151.                 <component class="org.seasar.jsf.selector.InputTextareaSelector"/>
  152.             </arg>
  153.         </initMethod>
  154.         <initMethod name="addTagSelector">
  155.             <arg>
  156.                 <component class="org.seasar.jsf.selector.SelectBooleanCheckboxSelector"/>
  157.             </arg>
  158.         </initMethod>
  159.         <initMethod name="addTagSelector">
  160.             <arg>
  161.                 <component class="org.seasar.jsf.selector.SelectOneMenuSelector"/>
  162.             </arg>
  163.         </initMethod>
  164.         <initMethod name="addTagSelector">
  165.             <arg>
  166.                 <component class="org.seasar.jsf.selector.InputRadioSelector"/>
  167.             </arg>
  168.         </initMethod>
  169.         <initMethod name="addTagSelector">
  170.             <arg>
  171.                 <component class="org.seasar.jsf.selector.SelectManyListboxSelector"/>
  172.             </arg>
  173.         </initMethod>
  174.         <initMethod name="addTagSelector">
  175.             <arg>
  176.                 <component class="org.seasar.jsf.selector.ElementSelector"/>
  177.             </arg>
  178.         </initMethod>
  179.     </component>
  180.     <component class="org.seasar.jsf.runtime.ViewTemplateFactoryImpl"/>
  181.     <component class="org.seasar.jsf.runtime.ViewRendererImpl"/>
  182.     <component
  183.         name="webappConfigManager"
  184.         class="org.seasar.jsf.webapp.ServletContextWebappConfigManagerImpl">
  185.         <initMethod name="init"/>
  186.     </component>
  187. </components>

jsfErrorPage.dicon

  1. <?xml version="1.0" encoding="Shift_JIS"?>
  2. <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
  3.     "http://www.seasar.org/dtd/components24.dtd">
  4. <components namespace="jsfErrorPage" >
  5.     
  6.     <component class="org.seasar.jsf.runtime.ErrorPageManagerImpl">
  7.         <initMethod name="addErrorPage">
  8.             <arg>@org.seasar.framework.exception.SQLRuntimeException@class</arg>
  9.             <arg>"/errorpage/errorPageHsqldb.html"</arg>
  10.         </initMethod>
  11.         <initMethod name="addErrorPart">
  12.             <arg>@org.seasar.framework.exception.SQLRuntimeException@class</arg>
  13.             <arg>"/insert/errorPageHsqldb.html"</arg>
  14.         </initMethod>
  15.     </component>
  16. </components>

log4j.properties

  1. log4j.category.org.seasar=DEBUG, C
  2. log4j.additivity.org.seasar=false
  3. log4j.category.examples=DEBUG, C
  4. log4j.additivity.examples=false
  5. log4j.appender.C=org.apache.log4j.ConsoleAppender
  6. log4j.appender.C.Target=System.out
  7. log4j.appender.C.ImmediateFlush=true
  8. log4j.appender.C.layout=org.apache.log4j.PatternLayout
  9. log4j.appender.C.layout.ConversionPattern=%-5p %d [%t] %m%n
  10. log4j.rootLogger=INFO, A1
  11. log4j.appender.A1=org.apache.log4j.ConsoleAppender
  12. log4j.appender.A1.layout=org.apache.log4j.PatternLayout
  13. log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
  14. # myfaces logger
  15. log4j.logger.org.apache.myfaces=INFO
  16. log4j.logger.org.apache.myfaces.config=INFO
  17. log4j.logger.org.apache.myfaces.application=INFO
  18. log4j.logger.org.apache.myfaces.application.jsp=INFO
  19. log4j.logger.org.apache.myfaces.lifecycle=INFO
  20. log4j.logger.org.apache.myfaces.taglib=INFO
  21. log4j.logger.org.apache.myfaces.util.DebugUtils=INFO
  22. log4j.logger.org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl=WARN
  23. log4j.logger.org.apache.myfaces.renderkit.html.HtmlRenderKitImpl=WAR

teedaCustomize.dicon

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
  3.     "http://www.seasar.org/dtd/components24.dtd">
  4. <components>
  5.     <component class="org.seasar.teeda.core.render.DefaultComponentIdLookupStrategy" />
  6.     <component class="org.seasar.teeda.core.application.impl.DefaultComponentLookupStrategy" />
  7. </components>

teedaErrorPage.dicon

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN"
  3.     "http://www.seasar.org/dtd/components24.dtd">
  4. <components namespace="teedaErrorPage" >
  5.     <component class="org.seasar.teeda.core.util.ServletErrorPageManagerImpl"/>
  6. </components>

add/add.html

  1. <html xmlns:m="http://www.seasar.org/maya" m:extends="/WEB-INF/layout/layout.html">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j" />
  4. <title>Add</title>
  5. </head>
  6. <body>
  7. <span m:inject="f:param" m:name="layoutTitle" m:value="Add"/>
  8. <span m:inject="s:insert" m:name="body">
  9. <form>
  10. <span m:inject="h:messages" m:globalOnly="false" m:showDetail="true"/>
  11. <input type="text" m:value="#{addDto.arg1}"/> + 
  12. <input type="text" m:value="#{addDto.arg2}"/> = 
  13. <span m:value="#{addDto.result}"/>
  14. <input type="submit" value="calculate" m:action="#{addAction.calculate}"/>
  15. </form>
  16. </span>
  17. </body>
  18. </html>

hello/hello.html

  1. <html xmlns:m="http://www.seasar.org/maya" m:extends="/WEB-INF/layout/layout.html">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j" />
  4. <title>Hello</title>
  5. </head>
  6. <body>
  7. <span m:inject="f:param" m:name="layoutTitle" m:value="Hello"/>
  8. <span m:inject="s:insert" m:name="body">
  9. Hello <span m:value="#{helloDto.name}">hoge</span>
  10. <form action="hoge" m:passthrough="true"></form>
  11. </span>
  12. </body>
  13. </html>

WEB-INF/layout/csslayout.html

  1. <html xmlns:m="http://www.seasar.org/maya">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j" />
  4. <link rel="stylesheet" type="text/css" href="css/global.css"/>
  5. <title m:value="#{layoutTitle}">S2JSF Example</title>
  6. </head>
  7. <body>
  8. <div class="menu">
  9.     <span m:inject="s:insert" m:src="/WEB-INF/layout/menu.html"/>
  10. </div>
  11. <div class="level0">
  12.     <div class="level1">
  13.         <div class="header">
  14.             <span m:inject="s:insert" m:src="/WEB-INF/layout/header.html"/>
  15.         </div>
  16.         <div class="body">
  17.             <span m:inject="s:insert" m:name="body"/>
  18.         </div>
  19.     </div>
  20. </div>
  21. </body>
  22. </html>

WEB-INF/layout/footer.html

  1. <html xmlns:m="http://www.seasar.org/maya">
  2. <body>
  3. <span m:inject="s:insert">
  4. The Seasar Foundation
  5. </span>
  6. </body>
  7. </html>

WEB-INF/layout/header.html

  1. <html xmlns:m="http://www.seasar.org/maya">
  2. <body>
  3. <span m:inject="s:insert">
  4. <img m:inject="h:graphicImage" m:url="/images/seasar.gif"/>
  5. </span>
  6. </body>
  7. </html>

WEB-INF/layout/layout.html

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html xmlns:m="http://www.seasar.org/maya">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j" />
  5. <link m:inject="s:link" rel="stylesheet" type="text/css" href="/css/global.css"/>
  6. <title m:value="#{layoutTitle}"/>
  7. </head>
  8. <body>
  9. <table border="0" cellspacing="5">
  10. <tr>
  11.   <td colspan="2"><span m:inject="s:insert" m:src="/WEB-INF/layout/header.html"/></td>
  12. </tr>
  13. <tr>
  14.   <td width="140" valign="top">
  15.     <span m:inject="s:insert" m:src="/WEB-INF/layout/menu.html"/>
  16.   </td>
  17.   <td valign="top" align="left">
  18.     <span m:inject="s:insert" m:name="body"/>
  19.   </td>
  20. </tr>
  21. <tr>
  22.   <td colspan="2">
  23.     <hr/>
  24.   </td>
  25. </tr>
  26. <tr>
  27.   <td colspan="2">
  28.     <span m:inject="s:insert" m:src="/WEB-INF/layout/footer.html"/>
  29.   </td>
  30. </tr>
  31. </table>
  32. </body>
  33. </html>

WEB-INF/layout/menu.html

  1. <html xmlns:m="http://www.seasar.org/maya">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j" />
  4. <title>S2JSFExample</title>
  5. </head>
  6. <body>
  7. <span m:inject="s:insert">
  8. <form>
  9. <ul>
  10. <li>
  11. <a m:action="hello">Hello</a>
  12. </li>
  13. <li>
  14. <a m:action="add">Add</a>
  15. </li>
  16. </ul>
  17. </form>
  18. </span>
  19. </body>
  20. </html>

faces-config.xml

  1. <?xml version="1.0"?>
  2. <!DOCTYPE faces-config PUBLIC
  3.   "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
  4.   "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
  5. <faces-config>
  6.     <application>
  7.         <message-bundle>appMessages</message-bundle>
  8.         <locale-config>
  9.             <default-locale>en</default-locale>
  10.             <supported-locale>ja</supported-locale>
  11.         </locale-config>
  12.     </application>
  13.     <converter>
  14.         <converter-for-class>java.util.Date</converter-for-class>
  15.         <converter-class>org.seasar.jsf.convert.S2DateTimeConverter</converter-class>
  16.     </converter>
  17.     <navigation-rule>
  18.         <navigation-case>
  19.             <from-outcome>hello</from-outcome>
  20.             <to-view-id>/hello/hello.html</to-view-id>
  21.         </navigation-case>
  22.     </navigation-rule>
  23.     <navigation-rule>
  24.         <navigation-case>
  25.             <from-outcome>add</from-outcome>
  26.             <to-view-id>/add/add.html</to-view-id>
  27.             <redirect/>
  28.         </navigation-case>
  29.     </navigation-rule>
  30.     <lifecycle>
  31.         <phase-listener>org.seasar.teeda.core.event.PhaseChangeTracer</phase-listener>
  32.     </lifecycle>
  33. </faces-config>

web.xml

  1. <?xml version="1.0"?>
  2. <!DOCTYPE web-app PUBLIC
  3.   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  4.   "http://java.sun.com/dtd/web-app_2_3.dtd">
  5. <web-app>
  6.     <context-param>
  7.         <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  8.         <param-value>server</param-value>
  9.         <description>
  10.             State saving method: "client" or "server" (= default)
  11.             See JSF Specification 2.5.2
  12.         </description>
  13.     </context-param>
  14.     
  15.     <context-param>
  16.         <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
  17.         <param-value>.html</param-value>
  18.     </context-param>
  19.     <!-- Extensions Filter -->
  20.     <filter>
  21.         <filter-name>extensionsFilter</filter-name>
  22.         <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
  23.         <init-param>
  24.             <param-name>uploadMaxFileSize</param-name>
  25.             <param-value>100m</param-value>
  26.             <description>Set the size limit for uploaded files.
  27.                 Format: 10 - 10 bytes
  28.                         10k - 10 KB
  29.                         10m - 10 MB
  30.                         1g - 1 GB
  31.             </description>
  32.         </init-param>
  33.         <init-param>
  34.             <param-name>uploadThresholdSize</param-name>
  35.             <param-value>100k</param-value>
  36.             <description>Set the threshold size - files
  37.                     below this limit are stored in memory, files above
  38.                     this limit are stored on disk.
  39.                 Format: 10 - 10 bytes
  40.                         10k - 10 KB
  41.                         10m - 10 MB
  42.                         1g - 1 GB
  43.             </description>
  44.         </init-param>
  45.             <init-param>
  46.             <param-name>uploadRepositoryPath</param-name>
  47.             <param-value>/temp</param-value>
  48.             <description>Set the path where the intermediary files will be stored.
  49.             </description>
  50.         </init-param>
  51.     </filter>
  52.     <filter>
  53.         <filter-name>s2filter</filter-name>
  54.         <filter-class>org.seasar.framework.container.filter.S2ContainerFilter</filter-class>
  55.     </filter>
  56.     
  57.     <filter>
  58.         <filter-name>encodingfilter</filter-name>
  59.         <filter-class>org.seasar.extension.filter.EncodingFilter</filter-class>
  60.         <init-param>
  61.             <param-name>encoding</param-name>
  62.             <param-value>Windows-31j</param-value>
  63.         </init-param>
  64.     </filter>
  65.     <filter>
  66.         <filter-name>requestDumpFilter</filter-name>
  67.         <filter-class>examples.jsf.util.RequestDumpFilter</filter-class>
  68.     </filter>
  69.     
  70.     <!-- Extensions Filter -->
  71.     <filter-mapping>
  72.         <filter-name>extensionsFilter</filter-name>
  73.         <url-pattern>*.html</url-pattern>
  74.     </filter-mapping>
  75.     
  76.     <filter-mapping>
  77.         <filter-name>extensionsFilter</filter-name>
  78.         <url-pattern>/faces/*</url-pattern>
  79.     </filter-mapping>
  80.     <filter-mapping>
  81.         <filter-name>s2filter</filter-name>
  82.         <url-pattern>/*</url-pattern>
  83.     </filter-mapping>
  84.     
  85.     <filter-mapping>
  86.         <filter-name>encodingfilter</filter-name>
  87.         <url-pattern>*.html</url-pattern>
  88.     </filter-mapping>
  89.     <filter-mapping>
  90.         <filter-name>requestDumpFilter</filter-name>
  91.         <url-pattern>/*</url-pattern>
  92.     </filter-mapping>
  93.     <listener>
  94.         <listener-class>org.seasar.teeda.core.webapp.TeedaConfigureListener</listener-class>
  95.     </listener>
  96.     <!-- facesServlet -->
  97.     <servlet>
  98.         <servlet-name>facesServlet</servlet-name>
  99.         <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  100.         <load-on-startup>2</load-on-startup>
  101.     </servlet>
  102.     
  103.     <servlet>
  104.         <servlet-name>s2servlet</servlet-name>
  105.         <servlet-class>org.seasar.framework.container.servlet.S2ContainerServlet</servlet-class>
  106.         <init-param>
  107.             <param-name>debug</param-name>
  108.             <param-value>true</param-value>
  109.         </init-param>
  110.         <load-on-startup>1</load-on-startup>
  111.     </servlet>
  112.     
  113.     <servlet-mapping>
  114.         <servlet-name>facesServlet</servlet-name>
  115.         <url-pattern>*.html</url-pattern>
  116.     </servlet-mapping>
  117.     <servlet-mapping>
  118.         <servlet-name>s2servlet</servlet-name>
  119.         <url-pattern>/s2servlet</url-pattern>
  120.     </servlet-mapping>
  121.     <welcome-file-list>
  122.         <welcome-file>index.html</welcome-file>
  123.     </welcome-file-list>
  124. </web-app>

index.html

  1. <html xmlns:m="http://www.seasar.org/maya" m:extends="/WEB-INF/layout/layout.html">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=Windows-31j" />
  4. <title>S2JSFExample</title>
  5. </head>
  6. <body>
  7. <span m:inject="f:param" m:name="layoutTitle" m:value="Home"/>
  8. <span m:inject="s:insert" m:name="body">
  9. <h1>Welcome to S2JSF Example</h1>
  10. </span>
  11. </body>
  12. </html>

以上代码是从S2JSF自带的sample中抽出来的,更多用法还请下载S2JSF。

http://s2jsf.seasar.org/ja/

上例中使用的lib库均为S2JSF自带的sample中取得,列表如下:

aopalliance-1.0.jar
commons-beanutils-1.6.1.jar
commons-collections-3.1.jar
commons-el-1.0.jar
commons-fileupload-1.0.jar
commons-lang-2.1.jar
commons-logging-1.1.jar
geronimo-jsp_2.0_spec-1.0.jar
geronimo-jta_1.1_spec-1.0.jar
hsqldb-1.8.0.1.jar
javassist-3.4.ga.jar
jstl-1.1.2.jar
log4j-1.2.13.jar
nekohtml-0.9.3-nirvana.jar
ognl-2.6.7.jar
poi-2.5.1-final-20040804.jar
s2-dao-1.0.43.jar
s2-extension-2.4.13-sources.jar
s2-extension-2.4.13.jar
s2-framework-2.4.13-sources.jar
s2-framework-2.4.13.jar
s2-jsf-1.1.2-sources.jar
s2-jsf-1.1.2.jar
teeda-core-1.0.7-sources.jar
teeda-core-1.0.7.jar
teeda-extension-1.0.7.jar
tomahawk-1.1.1.jar
xercesImpl-2.6.2-sources.jar
xercesImpl-2.6.2.jar

你可能感兴趣的:(框架,jdbc,JSF,Class,insert,encoding)