文章转自:
http://blog.csdn.net/hgs_renyao/article/details/1770890
1、web.xml的配置
<?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" version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Spring 的配置 -->
<context-param>
<param-name>context</param-name>
<param-value>/WEB-INF/applicationContext</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Struts 的配置 -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- Velocity 的配置 -->
<servlet>
<servlet-name>velocity</servlet-name>
<servlet-class>
org.apache.velocity.tools.view.servlet.VelocityLayoutServlet
</servlet-class>
<init-param>
<param-name>org.apache.velocity.toolbox</param-name>
<param-value>/WEB-INF/toolbox.xml</param-value>
</init-param>
<init-param>
<param-name>org.apache.velocity.properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>velocity</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>pages/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
2、applicationContext.xml的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!--数据库配置-->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${JDBC.Driver}</value>
</property>
<property name="url">
<value>${JDBC.ConnectionURL}</value>
</property>
<property name="username">
<value>${Username}</value>
</property>
<property name="password">
<value>${Password}</value>
</property>
</bean>
<!--与ibatis整合-->
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>WEB-INF/sql-map-config.xml</value>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="TransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<!--用户DAO配置-->
<bean id="blogDAO"
class="com.renyao.ryblog.DAO.DefaultBlogDAO">
<property name="sqlMapClient">
<ref local="sqlMapClient" />
</property>
</bean>
</beans>
3、sql-map-config.xml的配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings cacheModelsEnabled="true" enhancementEnabled="true"
lazyLoadingEnabled="true" maxRequests="32" maxSessions="10"
maxTransactions="5" useStatementNamespaces="false" />
<!--映射存放sql语句的xml文件资源-->
<sqlMap resource="com/renyao/ryblog/Blog.xml" />
</sqlMapConfig>
4、ibatis映射文件实例--Blog.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Blog">
<!--select,update,insert,delete. id名用于访问该资源,resultClass表示输出类型,parameterClass表示输入参数-->
<select id="getBlog" resultClass="com.renyao.ryblog.bean.Blog">
SELECT BID as bid , TITLE as title, CONTENT as content,
CREATETIME as createTime, MODIFYTIME as modifyTime, CREATER as
creator,STATUS as status ,ISOPEN as isOpen ,PICURL as picURL
FROM BLOG WHERE BID = #value#
</select>
<select id="getBlogByTitle"
resultClass="com.renyao.ryblog.bean.Blog">
SELECT BID as bid , TITLE as title, CONTENT as content,
CREATETIME as createTime, MODIFYTIME as modifyTime, CREATER as
creator,STATUS as status ,ISOPEN as isOpen ,PICURL as picURL
FROM BLOG WHERE TITLE like #value#
</select>
<select id="getAllBlog" resultClass="com.renyao.ryblog.bean.Blog">
SELECT BID as bid , TITLE as title, CONTENT as content,
CREATETIME as createTime, MODIFYTIME as modifyTime, CREATER as
creator,STATUS as status ,ISOPEN as isOpen ,PICURL as picURL
FROM BLOG
</select>
<insert id="insertBlog"
parameterClass="com.renyao.ryblog.bean.Blog">
INSERT INTO BLOG(TITLE,CONTENT,CREATETIME,MODIFYTIME) values
(#title#, #content#, #createTime#, #modifyTime#)
</insert>
<update id="updateBlog"
parameterClass="com.renyao.ryblog.bean.Blog">
UPDATE BLOG SET TITLE = #title#, CONTENT= #content#, MODIFYTIME=
#modifyTime# WHERE BID = #bid#
</update>
<delete id="deleteBlog"
parameterClass="java.lang.Integer">
DELETE BLOG WHERE BID = #bid#
</delete>
</sqlMap>
5、struts-config.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<!--主要是form-bean与action-mapping的配置,前者用于存放表单提交后的数据,后者指定处理Action-->
<form-beans>
<form-bean name="blogForm"
type="com.renyao.ryblog.form.BlogForm" />
</form-beans>
<global-exceptions />
<global-forwards>
<forward name="blog" path="/pages/blog.do?method=list"></forward>
</global-forwards>
<action-mappings>
<action input="/pages/blog_edit.htm" name="blogForm"
parameter="method" path="/pages/blog"
type="com.renyao.ryblog.action.BlogAction">
<forward name="list" path="/pages/blog.do?method=list" />
<forward name="success" path="/pages/blog_list.htm" />
<forward name="view" path="/pages/blog_detail.htm" />
</action>
<action input="/pages/blog_add.htm" name="blogForm"
parameter="method" path="/pages/blogadd"
type="com.renyao.ryblog.action.BlogAction">
<forward name="list" path="/pages/blog.do?method=list" />
</action>
</action-mappings>
<message-resources
parameter="com.renyao.ryblog.ApplicationResources" />
</struts-config>
6、整合velocity
将web.xml中指定的两个文件,toolbox.xml,velocity.properties放到相应的路径,还有vm_global_library.vm。
velocity.properties相应设置如下
<!--directory指定输出文件夹,template指定输出模板页-->
velocimacro.library = /WEB-INF/VM_global_library.vm
input.encoding=GBK
output.encoding=GBK
default.contentType=text/html; charset=GBK
tools.view.servlet.layout.directory=pages
tools.view.servlet.layout.default.template=default.htm
toolbox.xml工具箱设置示例
<?xml version="1.0"?>
<toolbox>
<tool>
<key>link</key>
<scope>request</scope>
<class>org.apache.velocity.tools.struts.StrutsLinkTool</class>
</tool>
</toolbox>
模板页代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Renyao Blog</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<base href="$link.baseRef">
</head>
<body>
#parse('pages/header.htm')
$screen_content
#parse('pages/footer.htm')
</body>
</html>
7、后台实现
需要编写的文件:Blog.xml,Blog.java,BlogForm.java,BlogAction.java,IBlogDAO.java---DAO接口,DefaultBlogDAO.java---实现
改进的地方:通过继承与接口优化代码结构
主要代码:
a.BaseAction.java
package com.renyao.ryblog.action;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.actions.DispatchAction;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class BaseAction extends DispatchAction{
private ApplicationContext ac;
protected Object getBean(String beanName){
return ac.getBean(beanName);
}
public void setServlet(ActionServlet actionServlet){
if(actionServlet!=null){
super.setServlet(actionServlet);
ac=WebApplicationContextUtils.getRequiredWebApplicationContext(actionServlet.getServletContext());
}
}
}
b.BlogAction.java
package com.renyao.ryblog.action;
import java.sql.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.renyao.ryblog.DAO.iface.IBlogDAO;
import com.renyao.ryblog.bean.Blog;
import com.renyao.ryblog.form.BlogForm;
public class BlogAction extends BaseAction {
public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try {
request.setAttribute("blogs", ((IBlogDAO) getBean("blogDAO"))
.getAllBlog());
return mapping.findForward("success");
} catch (Exception e) {
return mapping.getInputForward();
}
}
public ActionForward view(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int bid = Integer.parseInt(request.getParameter("bid"));
Blog blog = ((IBlogDAO) getBean("blogDAO")).getBlog(bid);
request.setAttribute("blog", blog);
return mapping.findForward("view");
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int bid = Integer.parseInt(request.getParameter("bid"));
((IBlogDAO) getBean("blogDAO")).deleteBlog(bid);
return mapping.findForward("list");
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int bid = Integer.parseInt(request.getParameter("bid"));
Date modifyTime = new Date(System.currentTimeMillis());
Blog blog = ((IBlogDAO) getBean("blogDAO")).getBlog(bid);
blog.setContent(((BlogForm)form).getContent());
blog.setTitle(((BlogForm)form).getTitle());
blog.setModifyTime(modifyTime);
((IBlogDAO)getBean("blogDAO")).updateBlog(blog);
return mapping.findForward("list");
}
public ActionForward insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Blog blog = null;
String title = ((BlogForm) form).getTitle();
String content = ((BlogForm) form).getContent();
Date date = new Date(System.currentTimeMillis());
blog.setContent(content);
blog.setTitle(title);
blog.setCreateTime(date);
blog.setModifyTime(date);
((IBlogDAO) getBean("blogDAO")).insertBlog(blog);
return mapping.findForward("list");
}
}
http://blog.csdn.net/hgs_renyao/article/details/1770890
1、web.xml的配置
<?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" version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Spring 的配置 -->
<context-param>
<param-name>context</param-name>
<param-value>/WEB-INF/applicationContext</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Struts 的配置 -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<!-- Velocity 的配置 -->
<servlet>
<servlet-name>velocity</servlet-name>
<servlet-class>
org.apache.velocity.tools.view.servlet.VelocityLayoutServlet
</servlet-class>
<init-param>
<param-name>org.apache.velocity.toolbox</param-name>
<param-value>/WEB-INF/toolbox.xml</param-value>
</init-param>
<init-param>
<param-name>org.apache.velocity.properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>velocity</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>pages/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
2、applicationContext.xml的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!--数据库配置-->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>${JDBC.Driver}</value>
</property>
<property name="url">
<value>${JDBC.ConnectionURL}</value>
</property>
<property name="username">
<value>${Username}</value>
</property>
<property name="password">
<value>${Password}</value>
</property>
</bean>
<!--与ibatis整合-->
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>WEB-INF/sql-map-config.xml</value>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="TransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<!--用户DAO配置-->
<bean id="blogDAO"
class="com.renyao.ryblog.DAO.DefaultBlogDAO">
<property name="sqlMapClient">
<ref local="sqlMapClient" />
</property>
</bean>
</beans>
3、sql-map-config.xml的配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings cacheModelsEnabled="true" enhancementEnabled="true"
lazyLoadingEnabled="true" maxRequests="32" maxSessions="10"
maxTransactions="5" useStatementNamespaces="false" />
<!--映射存放sql语句的xml文件资源-->
<sqlMap resource="com/renyao/ryblog/Blog.xml" />
</sqlMapConfig>
4、ibatis映射文件实例--Blog.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Blog">
<!--select,update,insert,delete. id名用于访问该资源,resultClass表示输出类型,parameterClass表示输入参数-->
<select id="getBlog" resultClass="com.renyao.ryblog.bean.Blog">
SELECT BID as bid , TITLE as title, CONTENT as content,
CREATETIME as createTime, MODIFYTIME as modifyTime, CREATER as
creator,STATUS as status ,ISOPEN as isOpen ,PICURL as picURL
FROM BLOG WHERE BID = #value#
</select>
<select id="getBlogByTitle"
resultClass="com.renyao.ryblog.bean.Blog">
SELECT BID as bid , TITLE as title, CONTENT as content,
CREATETIME as createTime, MODIFYTIME as modifyTime, CREATER as
creator,STATUS as status ,ISOPEN as isOpen ,PICURL as picURL
FROM BLOG WHERE TITLE like #value#
</select>
<select id="getAllBlog" resultClass="com.renyao.ryblog.bean.Blog">
SELECT BID as bid , TITLE as title, CONTENT as content,
CREATETIME as createTime, MODIFYTIME as modifyTime, CREATER as
creator,STATUS as status ,ISOPEN as isOpen ,PICURL as picURL
FROM BLOG
</select>
<insert id="insertBlog"
parameterClass="com.renyao.ryblog.bean.Blog">
INSERT INTO BLOG(TITLE,CONTENT,CREATETIME,MODIFYTIME) values
(#title#, #content#, #createTime#, #modifyTime#)
</insert>
<update id="updateBlog"
parameterClass="com.renyao.ryblog.bean.Blog">
UPDATE BLOG SET TITLE = #title#, CONTENT= #content#, MODIFYTIME=
#modifyTime# WHERE BID = #bid#
</update>
<delete id="deleteBlog"
parameterClass="java.lang.Integer">
DELETE BLOG WHERE BID = #bid#
</delete>
</sqlMap>
5、struts-config.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<!--主要是form-bean与action-mapping的配置,前者用于存放表单提交后的数据,后者指定处理Action-->
<form-beans>
<form-bean name="blogForm"
type="com.renyao.ryblog.form.BlogForm" />
</form-beans>
<global-exceptions />
<global-forwards>
<forward name="blog" path="/pages/blog.do?method=list"></forward>
</global-forwards>
<action-mappings>
<action input="/pages/blog_edit.htm" name="blogForm"
parameter="method" path="/pages/blog"
type="com.renyao.ryblog.action.BlogAction">
<forward name="list" path="/pages/blog.do?method=list" />
<forward name="success" path="/pages/blog_list.htm" />
<forward name="view" path="/pages/blog_detail.htm" />
</action>
<action input="/pages/blog_add.htm" name="blogForm"
parameter="method" path="/pages/blogadd"
type="com.renyao.ryblog.action.BlogAction">
<forward name="list" path="/pages/blog.do?method=list" />
</action>
</action-mappings>
<message-resources
parameter="com.renyao.ryblog.ApplicationResources" />
</struts-config>
6、整合velocity
将web.xml中指定的两个文件,toolbox.xml,velocity.properties放到相应的路径,还有vm_global_library.vm。
velocity.properties相应设置如下
<!--directory指定输出文件夹,template指定输出模板页-->
velocimacro.library = /WEB-INF/VM_global_library.vm
input.encoding=GBK
output.encoding=GBK
default.contentType=text/html; charset=GBK
tools.view.servlet.layout.directory=pages
tools.view.servlet.layout.default.template=default.htm
toolbox.xml工具箱设置示例
<?xml version="1.0"?>
<toolbox>
<tool>
<key>link</key>
<scope>request</scope>
<class>org.apache.velocity.tools.struts.StrutsLinkTool</class>
</tool>
</toolbox>
模板页代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Renyao Blog</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<base href="$link.baseRef">
</head>
<body>
#parse('pages/header.htm')
$screen_content
#parse('pages/footer.htm')
</body>
</html>
7、后台实现
需要编写的文件:Blog.xml,Blog.java,BlogForm.java,BlogAction.java,IBlogDAO.java---DAO接口,DefaultBlogDAO.java---实现
改进的地方:通过继承与接口优化代码结构
主要代码:
a.BaseAction.java
package com.renyao.ryblog.action;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.actions.DispatchAction;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
public class BaseAction extends DispatchAction{
private ApplicationContext ac;
protected Object getBean(String beanName){
return ac.getBean(beanName);
}
public void setServlet(ActionServlet actionServlet){
if(actionServlet!=null){
super.setServlet(actionServlet);
ac=WebApplicationContextUtils.getRequiredWebApplicationContext(actionServlet.getServletContext());
}
}
}
b.BlogAction.java
package com.renyao.ryblog.action;
import java.sql.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.renyao.ryblog.DAO.iface.IBlogDAO;
import com.renyao.ryblog.bean.Blog;
import com.renyao.ryblog.form.BlogForm;
public class BlogAction extends BaseAction {
public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try {
request.setAttribute("blogs", ((IBlogDAO) getBean("blogDAO"))
.getAllBlog());
return mapping.findForward("success");
} catch (Exception e) {
return mapping.getInputForward();
}
}
public ActionForward view(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int bid = Integer.parseInt(request.getParameter("bid"));
Blog blog = ((IBlogDAO) getBean("blogDAO")).getBlog(bid);
request.setAttribute("blog", blog);
return mapping.findForward("view");
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int bid = Integer.parseInt(request.getParameter("bid"));
((IBlogDAO) getBean("blogDAO")).deleteBlog(bid);
return mapping.findForward("list");
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int bid = Integer.parseInt(request.getParameter("bid"));
Date modifyTime = new Date(System.currentTimeMillis());
Blog blog = ((IBlogDAO) getBean("blogDAO")).getBlog(bid);
blog.setContent(((BlogForm)form).getContent());
blog.setTitle(((BlogForm)form).getTitle());
blog.setModifyTime(modifyTime);
((IBlogDAO)getBean("blogDAO")).updateBlog(blog);
return mapping.findForward("list");
}
public ActionForward insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
Blog blog = null;
String title = ((BlogForm) form).getTitle();
String content = ((BlogForm) form).getContent();
Date date = new Date(System.currentTimeMillis());
blog.setContent(content);
blog.setTitle(title);
blog.setCreateTime(date);
blog.setModifyTime(date);
((IBlogDAO) getBean("blogDAO")).insertBlog(blog);
return mapping.findForward("list");
}
}
发表评论
-
spring data jpa
2014-10-03 22:23 652http://www.ibm.com/developerwor ... -
quartz
2014-09-19 16:26 535基本讲解: http://www.blogjava ... -
数据库读写分离
2014-06-18 20:29 1790java代码: http://blog.csdn. ... -
zookeeper
2014-03-29 14:31 0http://wenku.baidu.com/view/6ad ... -
shiro 使用手册 cas and shiro
2013-07-23 13:54 745http://www.360doc.com/content ... -
shiro code analysis
2013-07-16 14:44 1代码分析 http://blog.csdn.net/ja ... -
在Spring中使用Hessian Remoting技术
2013-07-03 17:14 590http://blog.csdn.net/caihaijian ... -
spring 依赖注入源码,AOP源码
2013-05-18 14:24 571Aop 代码: http://www.goldendoc ... -
hadoop
2013-05-13 20:02 742http://hadoop.group.iteye.com/ ... -
Spring事务配置方式和spring里面事务的传播属性和事务隔离级别
2013-04-17 22:01 433http://blog.csdn.net/it_man/art ... -
Spring源代码解析
2013-04-13 20:56 717Spring源代码解析(收藏) Spring源代 ... -
spring 拦截
2013-04-11 14:28 649http://jiwenke-spring.blogspot. ... -
Spring MVC中的HandlerMapping
2013-04-03 16:43 842http://blog.csdn.net/prince2270 ... -
spring rmi
2013-04-01 18:09 552link:http://blog.csdn.net/shi ... -
Spring transactionmanager
2013-03-14 23:29 774from :http://www.cnblogs.com/r ... -
SimpleFormController
2012-12-02 17:06 720百度文库地址: h ... -
Spring事物管理
2012-11-19 13:50 664文章来自:http://blog.csdn.net/da ... -
Spring Bean 生命周期
2011-12-28 14:43 1105Bean生命周期涉及到的方 ... -
DispatcherServlet被初始化的源头
2011-10-16 15:52 769web 服务器初始化: 首先SttpServletBean 继 ... -
Spring 事务机制
2011-10-15 21:50 769文章转自:http://blog.csdn.net/lenol ...
相关推荐
Struts2、Spring和iBatis是Java Web开发中三个非常重要的开源框架,它们共同构建了一个灵活、可扩展且高效的应用程序开发环境。这个“struts2+spring+iBatis框架包”集成了这三个框架,使得开发者能够快速构建基于...
通过Struts2、Spring和iBatis的整合,我们可以实现模型、视图和控制的分离,提高代码的可读性和可维护性。同时,Spring的DI和AOP特性使得对象管理更加灵活,iBatis则提供了方便的数据库操作方式。这样的组合在企业级...
5. 整合过程:通常,整合这三大框架需要配置Struts2的struts.xml、Spring的applicationContext.xml以及iBatis的sqlMapConfig.xml等文件。还需要在Struts2的Action类中注入Spring管理的bean,以便于调用业务服务。...
但是,你可以参考上述的整合步骤,结合实际的项目需求,配置自己的Spring、Struts2和iBatis环境。记得在配置文件中仔细设置各个框架的连接,以确保它们能够协同工作。在开发过程中,合理利用这三个框架的优点,可以...
在这个架构中,Spring作为“粘合剂”将Struts2和Ibatis整合在一起。例如,Spring可以管理Struts2的Action实例,提供事务控制,并通过AOP进行异常处理。Ibatis则作为数据访问层,负责与数据库交互,Spring可以通过DAO...
在IT领域,构建高效、可扩展的企业级应用是至关重要的,而"Ext2.0+Struts2+Spring2.5+Ibatis2"的组合就是一种常见的技术栈,用于实现这样的目标。这个技术组合提供了从用户界面到数据访问的全方位解决方案。 **Ext...
在本项目整合中,我们将探讨如何将三个著名的技术框架——Spring、Struts2和IBatis——集成在一起,创建一个高效且灵活的企业级Web应用程序。这个整合通常被称为SSH(Spring、Struts2、Hibernate或iBatis)框架栈,...
《基于Maven的Spring、Struts2、iBatis与Velocity整合实践》 在Web开发领域,Spring、Struts2、iBatis和Velocity是四个非常重要的组件,它们各自承担着不同的职责,共同构建出高效、灵活的Web应用程序。本实例以...
Struts2.0、Spring、iBatis和JSON是Java Web开发中常用的技术栈,它们在构建企业级应用中发挥着关键作用。这篇详细的解释将深入探讨这些技术以及它们如何协同工作。 首先,Struts2.0是一个基于MVC(模型-视图-控制...
1. **配置文件**:如struts.xml、spring-servlet.xml、ibatis的sqlMapConfig.xml等,这些文件分别定义了Struts2、Spring和iBatis的配置信息。 2. **Action类**:实现业务逻辑,通常继承自Struts2的ActionSupport类,...
在与Spring整合时,iBatis可以作为Spring的数据访问层组件,通过SqlSessionFactory和SqlSessionTemplate等类进行配置,使得数据库操作可以通过DAO(Data Access Object)模式进行。 整合Struts2、Spring和iBatis的...
《Spring3+Struts2+Ibatis:企业级应用开发框架整合详解》 在现代企业级Web应用开发中,Spring、Struts2和Ibatis是常见的三大组件,它们各自负责不同的职责,共同构建出高效、灵活的应用架构。Spring作为全能型的...
Struts2+Spring+Ibatis(SSI2)整合项目是一个常见的Java Web开发框架组合,用于构建高效、可扩展的企业级应用程序。这个项目提供了一个全面的示例,特别适合初学者学习和理解这三大框架的集成与协作。下面将详细...
在"demo"这个压缩包中,可能包含了一个使用Struts2、Spring和iBatis搭建的示例项目,可能包括了配置文件(如struts.xml、spring-context.xml、ibatis配置文件)、Action类、Service接口及实现、Mapper接口及XML配置...
Struts2、Spring、iBatis 和 ExtJS 是四个在Web开发领域中广泛使用的开源技术。这个小型应用系统结合了这些技术,构建了一个高效、灵活的解决方案。 **Struts2** 是一个基于MVC(Model-View-Controller)设计模式的...
Struts2、Spring3、iBatis2.3和jQuery_AJAX1.7是经典的Java Web开发技术栈,它们各自扮演着不同的角色,构建出高效、灵活的应用系统。Struts2是一个MVC(Model-View-Controller)框架,负责处理用户请求并控制应用...
Struts2、Spring、iBatis和jQuery是四个在Java Web开发中广泛应用的框架和技术,它们共同构建了一个高效、灵活的后端系统,并通过JSON进行数据交互。下面将详细阐述这些技术及其相互间的整合。 **Struts2** 是一个...
标题 "ssi struts2+spring+ibatis oracle lib" 提供了关于这个压缩包的核心信息,它包含了在Java开发中常用的三个框架——Struts2、Spring和iBatis的库文件,以及可能与Oracle数据库相关的组件。这个组合常用于构建...
这个"struts2_iBATIS_spring"压缩包文件包含了整合这三个框架所需的源代码和配置文件,开发者可以通过学习和实践这些示例,加深对Struts2、iBATIS和Spring整合的理解,并运用到实际项目中。这种整合方式在Java Web...
1. **Spring** 配置:首先,需要配置Spring的ApplicationContext,声明Struts2和iBatis的相关bean,如Action类、DAO接口及其实现、SqlSessionFactory等。Spring的DI特性使得这些组件之间的依赖关系可以通过配置文件...