工程目录
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>android</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- 第一 这个过滤器与Struts的核心过滤器协同工作,以便更容易与sitemesh整合 -->
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<!-- 第二 sitemesh的过滤器,同时也整合了Freemarker -->
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>org.apache.struts2.sitemesh.FreeMarkerPageFilter</filter-class>
</filter>
<!-- 第三 struts2过滤器 -->
<filter>
<filter-name>struts2Filter</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--
使FreeMarker模块能够使用strut2标签,使用方式:<#assign
s=JspTaglibs["/WEB-INF/struts-tags.tld"] />
-->
<servlet>
<servlet-name>JspSupportservlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>sitemesh-freemarker</servlet-name>
<servlet-class>com.opensymphony.module.sitemesh.freemarker.FreemarkerDecoratorServlet</servlet-class>
<init-param>
<param-name>TemplatePath</param-name>
<param-value>/</param-value>
</init-param>
<init-param>
<param-name>default_encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sitemesh-freemarker</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.convention.default.parent.package" value="crud-default" />
<constant name="struts.convention.package.locators" value="action" />
<constant name="struts.convention.package.locators.basePackage" value="org.david.android" />
<constant name="struts.convention.result.path" value="/WEB-INF/web" />
<!-- 用于CRUD Action的parent package -->
<package name="crud-default" extends="convention-default">
<!-- 基于paramsPrepareParamsStack,
增加store interceptor保证actionMessage在redirect后不会丢失 -->
<interceptors>
<interceptor-stack name="crudStack">
<interceptor-ref name="store">
<param name="operationMode">AUTOMATIC</param>
</interceptor-ref>
<interceptor-ref name="paramsPrepareParamsStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="crudStack" />
</package>
<!--
使用Convention插件,实现约定大于配置的零配置文件风格.
特殊的Result路径在Action类中使用@Result设定.
-->
</struts>
decorators.xml
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/WEB-INF/decorators">
<decorator name="main" page="main.ftl">
<pattern>/*</pattern>
</decorator>
</decorators>
HelloWorldAction.java
package org.david.android.action.user;
public class HelloWorldAction {
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String execute(){
this.message = "ITdavid";
return "success";
}
}
main.ftl
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>${title}</title>
</head>
<body>
<div>
hello
${body}
</body>
</html>
hello-world.ftl
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="layout" content="main"/>
<title>Insert title here</title>
</head>
<body>
Hello ${message!}
</body>
</html>
posted @
2009-11-29 17:05 大卫 阅读(3286) |
评论 (4) |
编辑 收藏
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>fmtest</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/service-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<display-name>Stripes Filter</display-name>
<filter-name>StripesFilter</filter-name>
<filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
<init-param>
<param-name>ActionResolver.Packages</param-name>
<param-value>net.sourceforge.stripes.examples</param-value>
</init-param>
<init-param>
<param-name>Interceptor.Classes</param-name>
<param-value>net.sourceforge.stripes.integration.spring.SpringInterceptor</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>StripesFilter</filter-name>
<servlet-name>StripesDispatcher</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>StripesDispatcher</servlet-name>
<servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>StripesDispatcher</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Freemarker</servlet-name>
<servlet-class>freemarker.ext.servlet.FreemarkerServlet</servlet-class>
<init-param>
<param-name>TemplatePath</param-name>
<param-value>/</param-value>
</init-param>
<init-param>
<param-name>template_update_delay</param-name>
<param-value>0</param-value> <!-- 0 is for dev only! Use higher value otherwise. -->
</init-param>
<init-param>
<param-name>DefaultEncoding</param-name>
<param-value>utf-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Freemarker</servlet-name>
<url-pattern>*.ftl</url-pattern>
</servlet-mapping>
</web-app>
posted @
2009-11-25 15:45 大卫 阅读(1748) |
评论 (2) |
编辑 收藏
解决FreeMarker中文乱码问题。
在web.xml中配置如下:
<servlet>
<servlet-name>Freemarker</servlet-name>
<servlet-class>freemarker.ext.servlet.FreemarkerServlet</servlet-class>
<init-param>
<param-name>TemplatePath</param-name>
<param-value>/</param-value>
</init-param>
<init-param>
<param-name>template_update_delay</param-name>
<param-value>3600</param-value> <!-- 0 值仅用于开发环境,生产环境请设置为3600或者更大。 -->
</init-param>
<init-param>
<param-name>DefaultEncoding</param-name> <!-- 解决中文编码问题 -->
<param-value>utf-8</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
--------------------
PES准高手
posted @
2009-11-25 15:02 大卫 阅读(5059) |
评论 (1) |
编辑 收藏
RT
太保守会影响效率,当某些代码逻辑是认为可控制时,不用保守。
posted @
2009-09-28 10:08 大卫 阅读(422) |
评论 (0) |
编辑 收藏
关于类的划分,上层应该按业务领域含义划分,下层应该按实现细节划分。
posted @
2009-09-27 12:10 大卫 阅读(409) |
评论 (0) |
编辑 收藏
其实很简单,就把标记@Id放在主键(非自增)上就OK了。
posted @
2009-02-25 14:12 大卫 阅读(2547) |
评论 (0) |
编辑 收藏
摘要: 在设计数据库表的时候,往往会设计出带有复合主键的表,即表的记录由多个字段联合标识,如:
表
CREATE TABLE TB_HOUR_DATA
(
STAT_DATE DATE &...
阅读全文
posted @
2009-02-25 14:10 大卫 阅读(2998) |
评论 (2) |
编辑 收藏
如何调用执行iframe中的方法?如下:
document.getElementById("iframeId").contentWindow.functionName();
posted @
2008-10-07 14:50 大卫 阅读(5348) |
评论 (5) |
编辑 收藏
http://www.nciku.com/
这个网站里面的手写输入真棒!
posted @
2008-09-19 14:15 大卫 阅读(1271) |
评论 (1) |
编辑 收藏
最近用smartdraw画了一些结构图,感觉比visio之类好用,而且也包罗万象,推荐一下!
下载地址:http://soft.mumayi.net/downinfo/3393.html
posted @
2008-09-18 14:04 大卫 阅读(1848) |
评论 (2) |
编辑 收藏
/**//* 判断是否含有GBK以外的特殊字符 */
boolean isGBK(String s) throws UnsupportedEncodingException
{
if(s.equals(new String(s.getBytes("gbk"))))
return true;
else
return false;
}
posted @
2008-09-16 13:04 大卫 阅读(873) |
评论 (1) |
编辑 收藏
使用这个组合,感觉还是很方便灵活的。
1、将struts2的json插件加入web工程的lib,jsonplugin的下载地址:
http://code.google.com/p/jsonplugin/downloads/list
2、struts.xml添加专为ajax使用的package
<package name="ajax" extends="json-default">
<action name="ajaxRequest"
class="org.david.struts2.HelloWorld">
<result type="json"></result>
</action>
</package>
3、helloworld.jsp
<SCRIPT type="text/javascript" src="js/jquery-1.2.6.min.js"></script>
<SCRIPT type="text/javascript">
function clickButton()
{
var url = 'ajaxRequest.action';
var params = {
name:$('#name').attr('value')
};
jQuery.post(url, params, callbackFun, 'json');
}
function callbackFun(data)
{
alert(data.result);//对应HelloWorld类的message属性
//获取数据后渲染页面
}
</SCRIPT>
<input id="name" type="text">
<input type="button" value="ok" onclick="javascript:clickButton();">
4、HelloWorld.java
package org.david.struts2;
public class HelloWorld {
private String name;
private String result;
// ajax请求参数赋值
public void setName(String name) {
this.name = name;
}
// ajax返回结果
public String getResult() {
return result;
}
public String execute() {
this.result = "Hello! " + this.name + ".";
return "success";
}
}
posted @
2008-09-07 23:07 大卫 阅读(41952) |
评论 (17) |
编辑 收藏
鼠标手型代码:
this.style.cursor='pointer'
不要用hand,否则firefox无效。
posted @
2008-08-01 17:03 大卫 阅读(2332) |
评论 (1) |
编辑 收藏
word-wrap:break-word 在firefox中不会起作用,以下是解决办法:
完整的css代码为
word-wrap:break-word; overflow:hidden;
这段代码应添加到td标签的样式中。另外,应该在外层的table标签中添加样式
table-layout:fixed;
posted @
2008-07-11 13:34 大卫 阅读(2100) |
评论 (1) |
编辑 收藏
(.|\s)*
posted @
2008-06-23 14:49 大卫 阅读(921) |
评论 (0) |
编辑 收藏