------------------------------------------/mytest/src/com/test/bean/User.java
package com.test.bean;
public class User {
private int id;
private String firstname;
private String lastname;
private int age;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
--------------------------------------------/mytest/src/com/test/bean/User.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.test.bean.User" table="users">
<id name="id" column="id">
<generator class="increment"></generator>
</id>
<property name="firstname" column="firstname"
length="50">
</property>
<property name="lastname" column="lastname"
length="50">
</property>
<property name="age" column="age"></property>
</class>
</hibernate-mapping>
--------------------------------------/mytest/src/com/test/bean/User-user-validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
<field name="firstname">
<field-validator type="requiredstring">
<message>required first name</message>
</field-validator>
</field>
<field name="lastname">
<field-validator type="requiredstring">
<message>required last name</message>
</field-validator>
</field>
<field name="age">
<field-validator type="required">
<message>required age</message>
</field-validator>
<field-validator type="int">
<param name="min">1</param>
<param name="max">150</param>
<message>age should be between ${min} and ${max}</message>
</field-validator>
</field>
</validators>
---------------------------------------------------/mytest/src/com/test/dao/UserDAO.java
package com.test.dao;
import java.util.List;
import com.test.bean.User;
public interface UserDAO {
public void save(User user);
public void remove(User user);
public void update(User user);
public User findUserById(int id);
public List<User> findAllUsers();
}
-------------------------------/mytest/src/com/test/dao/impl/UserDAOImpl.java
package com.test.dao.impl;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.test.bean.User;
import com.test.dao.UserDAO;
public class UserDAOImpl extends HibernateDaoSupport implements UserDAO {
@SuppressWarnings("unchecked")
public List<User> findAllUsers() {
String sql="from User user order by user.id desc";
return (List<User>)this.getHibernateTemplate().find(sql);
}
public User findUserById(int id) {
User user=(User)this.getHibernateTemplate().get(User.class, id);
return user;
}
public void remove(User user) {
this.getHibernateTemplate().delete(user);
}
public void save(User user) {
this.getHibernateTemplate().save(user);
}
public void update(User user) {
this.getHibernateTemplate().update(user);
}
}
------------------------------------------/mytest/src/com/test/service/UserService.java
package com.test.service;
import java.io.InputStream;
import java.util.List;
import com.test.bean.User;
public interface UserService {
public List<User> findAll();
public User findById(int id);
public void save(User user);
public void delete(User user);
public void update(User user);
public InputStream getInputStream();
}
--------------------------------------/mytest/src/com/test/service/impl/UserServiceImpl.java
package com.test.service.impl;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import com.test.bean.User;
import com.test.dao.UserDAO;
import com.test.service.UserService;
import com.test.util.CharacterUtils;
public class UserServiceImpl implements UserService {
private UserDAO userDao;
public UserDAO getUserDao() {
return userDao;
}
public void setUserDao(UserDAO userDao) {
this.userDao = userDao;
}
public void delete(User user) {
this.userDao.remove(user);
}
public List<User> findAll() {
return this.userDao.findAllUsers();
}
public User findById(int id) {
return this.userDao.findUserById(id);
}
public void save(User user) {
this.userDao.save(user);
}
public void update(User user) {
this.userDao.update(user);
}
public InputStream getInputStream() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("sheet1");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell((short) 0);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("序号");
cell = row.createCell((short) 1);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("姓");
cell = row.createCell((short) 2);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("名");
cell = row.createCell((short) 3);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("年龄");
List<User> list = this.findAll();
for (int i = 0; i < list.size(); ++i)
{
User user = list.get(i);
row = sheet.createRow(i + 1);
cell = row.createCell((short) 0);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(i + 1);
cell = row.createCell((short) 1);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(user.getFirstname());
cell = row.createCell((short) 2);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(user.getLastname());
cell = row.createCell((short) 3);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(user.getAge());
}
String fileName=CharacterUtils.getRandomString(10);
fileName=new StringBuffer(fileName).append("xls").toString();
File file = new File(fileName);
try
{
OutputStream os = new FileOutputStream(file);
wb.write(os);
os.close();
}
catch (Exception e)
{
e.printStackTrace();
}
InputStream is = null;
try
{
is = new FileInputStream(file);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
return is;
}
}
--------------------------------------------------mytest/WebRoot/index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>operation</title>
</head>
<body>
<h1><font color="red">Operation List</font></h1>
<s:a href="save.jsp">Save User</s:a> <br><br><br>
<s:a href="listUser.action">List Users</s:a>
</body>
</html>
------------------------------------------------/mytest/WebRoot/list.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'list.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<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">
-->
<script type="text/javascript">
function del()
{
if(confirm("你真的想删除该记录么?"))
{
return true;
}
return false;
}
</script>
</head>
<body>
<h1><font color="red"><center>Users List</center></font></h1>
<table border="1" width="80%" align="center">
<tr>
<td>序号
</td>
<td>姓
</td>
<td>名
</td>
<td>年龄
</td>
<td>删除
</td>
<td>更新
</td>
</tr>
<s:iterator value="#request.list" id="us">
<tr>
<td><s:property value="#us.id"/>
</td>
<td><s:property value="#us.firstname"/>
</td>
<td><s:property value="#us.lastname"/>
</td>
<td><s:property value="#us.age"/>
</td>
<td><s:a href="deleteUser.action?user.id=%{#us.id}" onclick="return del();">delete</s:a>
</td>
<td><s:a href="updatePUser.action?user.id=%{#us.id}">update</s:a>
</td>
</tr>
</s:iterator>
</table>
<s:a href="index.jsp">Homepage</s:a><br><br>
<s:a href="generateExcel.action">生成excel</s:a>
</body>
</html>
-------------------------------------------------/mytest/WebRoot/save.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Save User</title>
</head>
<body>
<h1><font color="red">Save User</font></h1>
<s:form action="saveUser">
<s:textfield name="user.firstname" label="%{getText('firstname')}"></s:textfield>
<s:textfield name="user.lastname" label="%{getText('lastname')}"></s:textfield>
<s:textfield name="user.age" label="%{getText('age')}"></s:textfield>
<s:submit></s:submit>
</s:form>
</body>
</html>
------------------------------------------------------/mytest/WebRoot/update.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'update.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<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">
-->
</head>
<body>
<h1><font color="red">Update User</font></h1>
<s:form action="updateUser">
<table>
<tr>
<td>
<s:hidden name="user.id" value="%{user.id}"></s:hidden>
</td>
</tr>
<tr>
<td>
<s:textfield name="user.firstname" value="%{user.firstname}" label="%{getText('firstname')}"></s:textfield>
</td>
</tr>
<tr>
<td>
<s:textfield name="user.lastname" value="%{user.lastname}" label="%{getText('lastname')}"></s:textfield>
</td>
</tr>
<tr>
<td>
<s:textfield name="user.age" value="%{user.age}" label="%{getText('age')}"></s:textfield>
</td>
</tr>
<tr>
<td>
<s:submit></s:submit>
</td>
</tr>
</table>
</s:form>
</body>
</html>
------------------------------------------------/mytest/src/struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="user" extends="struts-default">
<action name="saveUser" class="saveUserAction">
<result name="success" type="redirect">listUser.action</result>
<result name="input">/save.jsp</result>
</action>
<action name="listUser" class="listUserAction">
<result>/list.jsp</result>
</action>
<action name="deleteUser" class="removeUserAction">
<result name="success" type="redirect">listUser.action</result>
</action>
<action name="updatePUser" class="updatePUserAction">
<result name="success">/update.jsp</result>
</action>
<action name="updateUser" class="updateUserAction">
<result name="success" type="redirect">listUser.action</result>
<result name="input">/update.jsp</result>
</action>
<action name="generateExcel" class="generateExcelAction">
<result name="success" type="stream">
<param name="contentType">application/vnd.ms-excel</param>
<param name="contentDisposition">inline;filename="AllUsers.xls"</param>
<param name="inputName">downloadFile</param>
</result>
</action>
</package>
</struts>
------------------------------------------------/mytest/src/struts.properties
struts.custom.i18n.resources=globalMessages
------------------------------/mytest/src/com/test/action/user/GenerateExcelAction.java
package com.test.action.user;
import java.io.InputStream;
import com.opensymphony.xwork2.ActionSupport;
import com.test.service.UserService;
public class GenerateExcelAction extends ActionSupport
{
private UserService service;
public UserService getService()
{
return service;
}
public void setService(UserService service)
{
this.service = service;
}
public InputStream getDownloadFile()
{
return this.service.getInputStream();
}
@Override
public String execute() throws Exception
{
return SUCCESS;
}
}
--------------------------------------/mytest/src/com/test/action/user/ListUserAction.java
package com.test.action.user;
import java.util.Map;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.test.service.UserService;
public class ListUserAction extends ActionSupport {
private UserService service;
public UserService getService() {
return service;
}
public void setService(UserService service) {
this.service = service;
}
@SuppressWarnings("unchecked")
public String execute() throws Exception
{
Map request = (Map) ActionContext.getContext().get("request");
request.put("list", service.findAll());
return SUCCESS;
}
}
----------------------------------/mytest/src/com/test/action/user/RemoveUserAction.java
package com.test.action.user;
import com.opensymphony.xwork2.ActionSupport;
import com.test.bean.User;
import com.test.service.UserService;
public class RemoveUserAction extends ActionSupport
{
private User user;
private UserService service;
public User getUser()
{
return user;
}
public void setUser(User user)
{
this.user = user;
}
public UserService getService()
{
return service;
}
public void setService(UserService service)
{
this.service = service;
}
@Override
public String execute() throws Exception
{
this.service.delete(user);
return SUCCESS;
}
}
-------------------------------/mytest/src/com/test/action/user/SaveUserAction.java
package com.test.action.user;
import com.opensymphony.xwork2.ActionSupport;
import com.test.bean.User;
import com.test.service.UserService;
public class SaveUserAction extends ActionSupport {
private User user;
private UserService service;
public UserService getService() {
return service;
}
public void setService(UserService service) {
this.service = service;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String execute() throws Exception {
this.service.save(this.user);
return "success";
}
}
---------------------------------------/mytest/src/com/test/action/user/UpdatePUserAction.java
package com.test.action.user;
import com.opensymphony.xwork2.ActionSupport;
import com.test.bean.User;
import com.test.service.UserService;
public class UpdatePUserAction extends ActionSupport {
private User user;
private UserService service;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public UserService getService() {
return service;
}
public void setService(UserService service) {
this.service = service;
}
public String execute(){
user=this.service.findById(user.getId());
return "success";
}
}
--------------------------------------/mytest/src/com/test/action/user/UpdateUserAction.java
package com.test.action.user;
import com.opensymphony.xwork2.ActionSupport;
import com.test.bean.User;
import com.test.service.UserService;
public class UpdateUserAction extends ActionSupport {
private User user;
private UserService service;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public UserService getService() {
return service;
}
public void setService(UserService service) {
this.service = service;
}
public String execute() {
this.service.update(user);
return "success";
}
}
------------------------------------/mytest/src/com/test/action/user/SaveUserAction-validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<!--<validators>
<field name="user.firstname">
<field-validator type="requiredstring">
<message>required first name</message>
</field-validator>
</field>
<field name="user.lastname">
<field-validator type="requiredstring">
<message>required last name</message>
</field-validator>
</field>
<field name="user.age">
<field-validator type="required">
<message>required age</message>
</field-validator>
<field-validator type="int">
<param name="min">1</param>
<param name="max">150</param>
<message>age should be between ${min} and ${max}</message>
</field-validator>
</field>
</validators>-->
<validators>
<field name="user">
<field-validator type="visitor">
<param name="context">user</param>
<param name="appendPrefix">true</param>
<message>user's </message>
</field-validator>
</field>
</validators>
--------------------------------------/mytest/src/com/test/action/user/UpdateUserAction-validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<!--<validators>
<field name="user.firstname">
<field-validator type="requiredstring">
<message>required first name</message>
</field-validator>
</field>
<field name="user.lastname">
<field-validator type="requiredstring">
<message>required last name</message>
</field-validator>
</field>
<field name="user.age">
<field-validator type="required">
<message>required age</message>
</field-validator>
<field-validator type="int">
<param name="min">1</param>
<param name="max">150</param>
<message>age should be between ${min} and ${max}</message>
</field-validator>
</field>
</validators>-->
<validators>
<field name="user">
<field-validator type="visitor">
<param name="context">user</param>
<param name="appendPrefix">true</param>
<message>user's </message>
</field-validator>
</field>
</validators>
-----------------------------------------/mytest/WebRoot/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
---------------------------------------/mytest/WebRoot/WEB-INF/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.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver"></property>
<property name="url" value="jdbc:db2://192.168.25.230:50000/JSAMPLE"></property>
<property name="username" value="zyl"></property>
<property name="password" value="123"></property>
<property name="maxActive" value="100"></property>
<property name="maxIdle" value="30"></property>
<property name="maxWait" value="500"></property>
<property name="defaultAutoCommit" value="true"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/test/bean/User.hbm.xml</value>
</list>
</property>
</bean>
<bean id="userDao" class="com.test.dao.impl.UserDAOImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userService" class="com.test.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean>
<bean id="saveUserAction" class="com.test.action.user.SaveUserAction"
scope="prototype">
<property name="service" ref="userService"></property>
</bean>
<bean id="listUserAction" class="com.test.action.user.ListUserAction"
scope="prototype">
<property name="service" ref="userService"></property>
</bean>
<bean id="removeUserAction" class="com.test.action.user.RemoveUserAction"
scope="prototype">
<property name="service" ref="userService"></property>
</bean>
<bean id="updatePUserAction" class="com.test.action.user.UpdatePUserAction"
scope="prototype">
<property name="service" ref="userService"></property>
</bean>
<bean id="updateUserAction" class="com.test.action.user.UpdateUserAction" scope="prototype">
<property name="service" ref="userService"></property>
</bean>
<bean id="generateExcelAction" class="com.test.action.user.GenerateExcelAction" scope="singleton">
<property name="service" ref="userService"></property>
</bean>
</beans>
---------------------------------------------------/mytest/WebRoot/WEB-INF/spring.tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>2.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>spring</short-name>
<uri>http://www.springframework.org/tags</uri>
<description>Spring Framework JSP Tag Library</description>
<tag>
<name>htmlEscape</name>
<tag-class>org.springframework.web.servlet.tags.HtmlEscapeTag</tag-class>
<body-content>JSP</body-content>
<description>
Sets default HTML escape value for the current page.
Overrides a "defaultHtmlEscape" context-param in web.xml, if any.
</description>
<attribute>
<name>defaultHtmlEscape</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<description>Set the default value for HTML escaping, to be put
into the current PageContext.</description>
</attribute>
</tag>
<tag>
<name>escapeBody</name>
<tag-class>org.springframework.web.servlet.tags.EscapeBodyTag</tag-class>
<body-content>JSP</body-content>
<description>
Escapes its enclosed body content, applying HTML escaping and/or JavaScript escaping.
The HTML escaping flag participates in a page-wide or application-wide setting
(i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).
</description>
<attribute>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set HTML escaping for this tag, as boolean value. Overrides the
default HTML escaping setting for the current page.</description>
</attribute>
<attribute>
<name>javaScriptEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set JavaScript escaping for this tag, as boolean value.
Default is false.</description>
</attribute>
</tag>
<tag>
<name>message</name>
<tag-class>org.springframework.web.servlet.tags.MessageTag</tag-class>
<body-content>JSP</body-content>
<description>
Retrieves the message with the given code, or text if code isn't resolvable.
The HTML escaping flag participates in a page-wide or application-wide setting
(i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).
</description>
<attribute>
<name>message</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>A MessageSourceResolvable argument (direct or through JSP EL).
Fits nicely when used in conjunction with Spring's own validation error
classes which all implement the MessageSourceResolvable interface. For
example, this allows you to iterate over all of the errors in a form,
passing each error (using a runtime expression) as the value of this
'message' attribute, thus effecting the easy display of such error
messages.</description>
</attribute>
<attribute>
<name>code</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The code (key) to use when looking up the message.
If code is not provided, the text attribute will be used.</description>
</attribute>
<attribute>
<name>arguments</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set optional message arguments for this tag, as a
(comma-)delimited String (each String argument can contain JSP EL),
an Object array (used as argument array), or a single Object (used
as single argument).</description>
</attribute>
<attribute>
<name>argumentSeparator</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The separator character to be used for splitting the
arguments string value; defaults to a 'comma' (',').</description>
</attribute>
<attribute>
<name>text</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Default text to output when a message for the given code
could not be found. If both text and code are not set, the tag will
output null.</description>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The string to use when binding the result to the page,
request, session or application scope. If not specified, the result
gets outputted to the writer (i.e. typically directly to the JSP).</description>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The scope to use when exporting the result to a variable.
This attribute is only used when var is also set. Possible values are
page, request, session and application.</description>
</attribute>
<attribute>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set HTML escaping for this tag, as boolean value.
Overrides the default HTML escaping setting for the current page.</description>
</attribute>
<attribute>
<name>javaScriptEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set JavaScript escaping for this tag, as boolean value. Default is false.</description>
</attribute>
</tag>
<tag>
<name>theme</name>
<tag-class>org.springframework.web.servlet.tags.ThemeTag</tag-class>
<body-content>JSP</body-content>
<description>
Retrieves the theme message with the given code, or text if code isn't resolvable.
The HTML escaping flag participates in a page-wide or application-wide setting
(i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).
</description>
<attribute>
<name>message</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>A MessageSourceResolvable argument (direct or through JSP EL).</description>
</attribute>
<attribute>
<name>code</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The code (key) to use when looking up the message.
If code is not provided, the text attribute will be used.</description>
</attribute>
<attribute>
<name>arguments</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set optional message arguments for this tag, as a
(comma-)delimited String (each String argument can contain JSP EL),
an Object array (used as argument array), or a single Object (used
as single argument).</description>
</attribute>
<attribute>
<name>argumentSeparator</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The separator character to be used for splitting the
arguments string value; defaults to a 'comma' (',').</description>
</attribute>
<attribute>
<name>text</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Default text to output when a message for the given code
could not be found. If both text and code are not set, the tag will
output null.</description>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The string to use when binding the result to the page,
request, session or application scope. If not specified, the result
gets outputted to the writer (i.e. typically directly to the JSP).</description>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The scope to use when exporting the result to a variable.
This attribute is only used when var is also set. Possible values are
page, request, session and application.</description>
</attribute>
<attribute>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set HTML escaping for this tag, as boolean value.
Overrides the default HTML escaping setting for the current page.</description>
</attribute>
<attribute>
<name>javaScriptEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set JavaScript escaping for this tag, as boolean value. Default is false.</description>
</attribute>
</tag>
<tag>
<name>hasBindErrors</name>
<tag-class>org.springframework.web.servlet.tags.BindErrorsTag</tag-class>
<body-content>JSP</body-content>
<description>
Provides Errors instance in case of bind errors.
The HTML escaping flag participates in a page-wide or application-wide setting
(i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).
</description>
<variable>
<name-given>errors</name-given>
<variable-class>org.springframework.validation.Errors</variable-class>
</variable>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<description>The name of the bean in the request, that needs to be
inspected for errors. If errors are available for this bean, they
will be bound under the 'errors' key.</description>
</attribute>
<attribute>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set HTML escaping for this tag, as boolean value.
Overrides the default HTML escaping setting for the current page.</description>
</attribute>
</tag>
<tag>
<name>nestedPath</name>
<tag-class>org.springframework.web.servlet.tags.NestedPathTag</tag-class>
<body-content>JSP</body-content>
<description>
Sets a nested path to be used by the bind tag's path.
</description>
<variable>
<name-given>nestedPath</name-given>
<variable-class>java.lang.String</variable-class>
</variable>
<attribute>
<name>path</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<description>Set the path that this tag should apply. E.g. 'customer'
to allow bind paths like 'address.street' rather than
'customer.address.street'.</description>
</attribute>
</tag>
<tag>
<name>bind</name>
<tag-class>org.springframework.web.servlet.tags.BindTag</tag-class>
<body-content>JSP</body-content>
<description>
Provides BindStatus object for the given bind path.
The HTML escaping flag participates in a page-wide or application-wide setting
(i.e. by HtmlEscapeTag or a "defaultHtmlEscape" context-param in web.xml).
</description>
<variable>
<name-given>status</name-given>
<variable-class>org.springframework.web.servlet.support.BindStatus</variable-class>
</variable>
<attribute>
<name>path</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<description>The path to the bean or bean property to bind status
information for. For instance account.name, company.address.zipCode
or just employee. The status object will exported to the page scope,
specifically for this bean or bean property</description>
</attribute>
<attribute>
<name>ignoreNestedPath</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set whether to ignore a nested path, if any. Default is to not ignore.</description>
</attribute>
<attribute>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set HTML escaping for this tag, as boolean value. Overrides
the default HTML escaping setting for the current page.</description>
</attribute>
</tag>
<tag>
<name>transform</name>
<tag-class>org.springframework.web.servlet.tags.TransformTag</tag-class>
<body-content>JSP</body-content>
<description>
Provides transformation of variables to Strings, using an appropriate
custom PropertyEditor from BindTag (can only be used inside BindTag).
The HTML escaping flag participates in a page-wide or application-wide setting
(i.e. by HtmlEscapeTag or a 'defaultHtmlEscape' context-param in web.xml).
</description>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<description>The value to transform. This is the actual object you want
to have transformed (for instance a Date). Using the PropertyEditor that
is currently in use by the 'spring:bind' tag.</description>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The string to use when binding the result to the page,
request, session or application scope. If not specified, the result gets
outputted to the writer (i.e. typically directly to the JSP).</description>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>The scope to use when exported the result to a variable.
This attribute is only used when var is also set. Possible values are
page, request, session and application.</description>
</attribute>
<attribute>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>Set HTML escaping for this tag, as boolean value. Overrides
the default HTML escaping setting for the current page.</description>
</attribute>
</tag>
</taglib>
-------------------------------------------/mytest/src/com/test/util/CharacterUtils.java
package com.test.util;
import java.util.Random;
public class CharacterUtils {
public static String getRandomString(int length) {
String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random= new Random();
StringBuffer sb=new StringBuffer();
for(int i=0;i<length;++i){
int number = random.nextInt(62);
sb.append(str.charAt(number));
}
return sb.toString();
}
// public static void main(String args[]){
// System.out.println(getRandomString(10));
// }
public static String getRandomString2(int length)
{
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; ++i)
{
int number = random.nextInt(3);
long result = 0;
switch (number)
{
case 0:
result = Math.round(Math.random() * 25 + 65);
sb.append(String.valueOf((char)result));
break;
case 1:
result = Math.round(Math.random() * 25 + 97);
sb.append(String.valueOf((char)result));
break;
case 2:
sb.append(String.valueOf(new Random().nextInt(10)));
break;
}
}
return sb.toString();
}
}
----------------------------------------------/mytest/src/com/test/util/ToDDL.java
package com.test.util;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class ToDDL {
public static void main(String[] args) {
Configuration configure = new Configuration();
configure.configure("hibernate.cfg.xml");
SchemaExport sc = new SchemaExport(configure);
sc.create(true, true);
}
}
----------------------------------------------/mytest/src/hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="myeclipse.connection.profile">zyl</property>
<property name="connection.url">
jdbc:db2://192.168.25.230:50000/JSAMPLE
</property>
<property name="connection.username">zyl</property>
<property name="connection.password">123</property>
<property name="connection.driver_class">
com.ibm.db2.jcc.DB2Driver
</property>
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>
<mapping resource="com/test/bean/User.hbm.xml" />
</session-factory>
</hibernate-configuration>
----------------------------------------------/mytest/src/globalMessages_en.properties
firstname=firstname
lastname=lastname
age=age
----------------------------------------------/mytest/src/globalMessages_zh.properties
firstname=\u59D3
lastname=\u540D
age=\u5E74\u9F84
---------------------------------------------/mytest/src/log4j.properties
log4j.rootLogger=ERROR,A1
log4j.appender.A1 = org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.TTCCLayout
---------------------------------------------------------
---------------------------------------------------------------
USERS表
键 名称 数据类型 长度 可空
主键 ID INTEGER 4 否
FIRSTNAME VARCHAR 50 是
LASTNAME VARCHAR 50 是
AGE INTEGER 4 是
------------------------------------------------------------------------------------
文件存放路径
mytest
/mytest/src
com.test.action.user
/mytest/src/com/test/action/user/GenerateExcelAction.java
/mytest/src/com/test/action/user/ListUserAction.java
/mytest/src/com/test/action/user/RemoveUserAction.java
/mytest/src/com/test/action/user/SaveUserAction.java
/mytest/src/com/test/action/user/UpdatePUserAction.java
/mytest/src/com/test/action/user/UpdateUserAction.java
/mytest/src/com/test/action/user/SaveUserAction-validation.xml
/mytest/src/com/test/action/user/UpdateUserAction-validation.xml
com.test.bean
/mytest/src/com/test/bean/User.java
/mytest/src/com/test/bean/User-user-validation.xml
/mytest/src/com/test/bean/User.hbm.xml
com.test.dao
/mytest/src/com/test/dao/UserDAO.java
com.test.dao.impl
/mytest/src/com/test/dao/impl/UserDAOImpl.java
com.test.service
/mytest/src/com/test/service/UserService.java
com.test.service.impl
/mytest/src/com/test/service/impl/UserServiceImpl.java
com.test.util
/mytest/src/com/test/util/CharacterUtils.java
/mytest/src/com/test/util/ToDDL.java
/mytest/src/globalMessages_en.properties
/mytest/src/globalMessages_zh.properties
/mytest/src/hibernate.cfg.xml
/mytest/src/log4j.properties
/mytest/src/struts.properties
/mytest/src/struts.xml
/mytest/WebRoot
/mytest/WebRoot/META-INF
/mytest/WebRoot/META-INF/MANIFEST.MF
/mytest/WebRoot/WEB-INF
/mytest/WebRoot/WEB-INF/lib
/mytest/WebRoot/WEB-INF/applicationContext.xml
/mytest/WebRoot/WEB-INF/spring-form.tld
/mytest/WebRoot/WEB-INF/spring.tld
/mytest/WebRoot/WEB-INF/web.xml
/mytest/WebRoot/index.jsp
/mytest/WebRoot/list.jsp
/mytest/WebRoot/save.jsp
/mytest/WebRoot/update.jsp
------------------------------------------------------------------
所需的包
/mytest/WebRoot/WEB-INF/lib/antlr-2.7.6.jar
/mytest/WebRoot/WEB-INF/lib/aopalliance.jar
/mytest/WebRoot/WEB-INF/lib/asm-attrs.jar
/mytest/WebRoot/WEB-INF/lib/asm-commons-2.2.3.jar
/mytest/WebRoot/WEB-INF/lib/asm-util-2.2.3.jar
/mytest/WebRoot/WEB-INF/lib/asm.jar
/mytest/WebRoot/WEB-INF/lib/aspectjrt.jar
/mytest/WebRoot/WEB-INF/lib/aspectjweaver.jar
/mytest/WebRoot/WEB-INF/lib/c3p0-0.9.1.2.jar
/mytest/WebRoot/WEB-INF/lib/cglib-2.1.3.jar
/mytest/WebRoot/WEB-INF/lib/cglib-nodep-2.1_3.jar
/mytest/WebRoot/WEB-INF/lib/commons-attributes-api.jar
/mytest/WebRoot/WEB-INF/lib/commons-attributes-compiler.jar
/mytest/WebRoot/WEB-INF/lib/commons-codec.jar
/mytest/WebRoot/WEB-INF/lib/commons-collections-2.1.1.jar
/mytest/WebRoot/WEB-INF/lib/commons-dbcp.jar
/mytest/WebRoot/WEB-INF/lib/commons-fileupload.jar
/mytest/WebRoot/WEB-INF/lib/commons-httpclient.jar
/mytest/WebRoot/WEB-INF/lib/commons-io.jar
/mytest/WebRoot/WEB-INF/lib/commons-lang.jar
/mytest/WebRoot/WEB-INF/lib/commons-logging-1.0.4.jar
/mytest/WebRoot/WEB-INF/lib/commons-logging.jar
/mytest/WebRoot/WEB-INF/lib/commons-pool.jar
/mytest/WebRoot/WEB-INF/lib/cos.jar
/mytest/WebRoot/WEB-INF/lib/dom4j-1.6.1.jar
/mytest/WebRoot/WEB-INF/lib/ehcache-1.2.3.jar
/mytest/WebRoot/WEB-INF/lib/ejb3-persistence.jar
/mytest/WebRoot/WEB-INF/lib/freemarker-2.3.15.jar
/mytest/WebRoot/WEB-INF/lib/freemarker.jar
/mytest/WebRoot/WEB-INF/lib/hibernate-annotations.jar
/mytest/WebRoot/WEB-INF/lib/hibernate-commons-annotations.jar
/mytest/WebRoot/WEB-INF/lib/hibernate-entitymanager.jar
/mytest/WebRoot/WEB-INF/lib/hibernate-validator.jar
/mytest/WebRoot/WEB-INF/lib/hibernate3.jar
/mytest/WebRoot/WEB-INF/lib/itext-1.3.jar
/mytest/WebRoot/WEB-INF/lib/jaas.jar
/mytest/WebRoot/WEB-INF/lib/jakarta-oro-2.0.8.jar
/mytest/WebRoot/WEB-INF/lib/jasperreports-1.3.4.jar
/mytest/WebRoot/WEB-INF/lib/javassist.jar
/mytest/WebRoot/WEB-INF/lib/jaxen-1.1-beta-7.jar
/mytest/WebRoot/WEB-INF/lib/jboss-archive-browsing.jar
/mytest/WebRoot/WEB-INF/lib/jdbc2_0-stdext.jar
/mytest/WebRoot/WEB-INF/lib/jotm.jar
/mytest/WebRoot/WEB-INF/lib/jta.jar
/mytest/WebRoot/WEB-INF/lib/jxl.jar
/mytest/WebRoot/WEB-INF/lib/log4j-1.2.11.jar
/mytest/WebRoot/WEB-INF/lib/log4j-1.2.14.jar
/mytest/WebRoot/WEB-INF/lib/mysql-connector-java-5.0.3-bin.jar
/mytest/WebRoot/WEB-INF/lib/ognl-2.7.3.jar
/mytest/WebRoot/WEB-INF/lib/persistence.jar
/mytest/WebRoot/WEB-INF/lib/poi-2.5.1.jar
/mytest/WebRoot/WEB-INF/lib/portlet-api.jar
/mytest/WebRoot/WEB-INF/lib/spring-agent.jar
/mytest/WebRoot/WEB-INF/lib/spring-aop.jar
/mytest/WebRoot/WEB-INF/lib/spring-beans.jar
/mytest/WebRoot/WEB-INF/lib/spring-context.jar
/mytest/WebRoot/WEB-INF/lib/spring-core.jar
/mytest/WebRoot/WEB-INF/lib/spring-dao.jar
/mytest/WebRoot/WEB-INF/lib/spring-hibernate3.jar
/mytest/WebRoot/WEB-INF/lib/spring-ibatis.jar
/mytest/WebRoot/WEB-INF/lib/spring-jdbc.jar
/mytest/WebRoot/WEB-INF/lib/spring-jdo.jar
/mytest/WebRoot/WEB-INF/lib/spring-jpa.jar
/mytest/WebRoot/WEB-INF/lib/spring-portlet.jar
/mytest/WebRoot/WEB-INF/lib/spring-struts.jar
/mytest/WebRoot/WEB-INF/lib/spring-tomcat-weaver.jar
/mytest/WebRoot/WEB-INF/lib/spring-toplink.jar
/mytest/WebRoot/WEB-INF/lib/spring-web.jar
/mytest/WebRoot/WEB-INF/lib/spring-webmvc.jar
/mytest/WebRoot/WEB-INF/lib/struts.jar
/mytest/WebRoot/WEB-INF/lib/struts2-core-2.1.8.jar
/mytest/WebRoot/WEB-INF/lib/struts2-spring-plugin-2.1.8.jar
/mytest/WebRoot/WEB-INF/lib/velocity-1.5.jar
/mytest/WebRoot/WEB-INF/lib/velocity-tools-view-1.3.jar
/mytest/WebRoot/WEB-INF/lib/xapool.jar
/mytest/WebRoot/WEB-INF/lib/xerces-2.6.2.jar
/mytest/WebRoot/WEB-INF/lib/xml-apis.jar
/mytest/WebRoot/WEB-INF/lib/xwork-core-2.1.6.jar
分享到:
相关推荐
综上所述,"mytest SSH之二"项目是一个基于Spring MVC的Java Web应用,可能也使用了Struts和Hibernate作为辅助框架。开发者可能在深入研究SSH框架的源码,优化工具链,并且通过`mytest-lib2`库实现特定的业务功能或...
【标题】"mytest(SSH).rar SSH mytest"是一个以SSH(Secure Shell)技术为核心的项目,名为"mytest"。SSH是一种网络协议,用于安全地远程登录到服务器,执行命令,传输数据,广泛应用于系统管理员和开发人员。在本...
这个名为"SSH整合小项目源代码mytest(SSH)"的资源提供了一个实际应用SSH框架的实例,帮助开发者理解如何在实际项目中将这三个框架有效地结合起来。下面我们将深入探讨SSH整合的核心概念、工作原理以及它在Web开发中...
这个名为"mytest(SSH).rar"的压缩包文件,显然是一个基于SSH框架开发的数据管理系统的项目源代码。下面将详细介绍SSH框架以及它们在数据管理中的应用。 1. **Struts2**:Struts2是一个基于MVC设计模式的Web应用框架...
mytest2 mytest2 mytest2
标题 "MyTest" 提供的信息有限,但从描述中提供的博文链接来看,我们可以推测这是一个关于IT技术分享的主题。虽然具体的细节没有直接给出,但链接指向了一篇由用户"kinphoo"在iteye博客上发布的文章,编号为1332671...
mytest1 mytest1 mytest1
【标题】"MyTest.zip" 是一个包含Hadoop练习代码的压缩文件,它暗示着我们即将探讨的是关于Hadoop分布式计算框架的相关知识。Hadoop是一个开源的Java框架,由Apache基金会维护,主要用于处理和存储海量数据。这个...
SSH(Struts2、Hibernate、Spring)是一个流行的Java Web开发框架,它整合了三大开源框架,为构建企业级应用提供了高效、稳定的基础。这个简单的SSH实例展示了如何利用这些技术实现用户登录注册、显示所有用户以及...
Mytest.Java
【标题】"人力资源管理系统(基于SSH)"是一个利用SSH(Struts2+Spring+Hibernate)技术构建的企业级应用,主要用于管理公司的人力资源信息。SSH是Java Web开发中常用的一个集成框架,它将表现层(Struts2)、业务...
SSH2,全称为Secure SHell version 2,是一种网络协议,用于在不安全的网络上安全地执行远程命令和传输数据。在这个“易懂的ssh2项目实例”中,我们很显然将要探讨如何在Java编程环境中使用SSH2库进行相关的操作。...
在IT行业中,SSH(Spring、Struts2和Hibernate)是一个常见的企业级Web应用程序开发框架组合。这个框架集合了Spring的依赖注入、Struts2的MVC设计模式以及Hibernate的对象关系映射,为开发者提供了强大的支持。现在...
mytest1mytest1mytest1mytest1mytest1mytest1mytest1mytest1mytest1
- **Action配置**:创建一个名为`personList`的Action,指定其类为`com.apache.mytest2.struts.PersonAction`,成功结果类型为`freemarker`,并将结果显示为`/WEB-INF/html/index.html`的Freemarker模板。...
SSH2整合分页是Web开发中的一个重要概念,SSH2指的是Spring、Struts2和Hibernate这三个开源框架的组合,它们在Java Web开发中被广泛应用。在这个场景下,"整合"意味着将这三个框架集成到一个项目中,以实现高效、...
- 实例化了一个`UntilData`对象并设置了属性。 - 创建了多个列表,并将它们存储到`request`对象中,以便在页面中使用。 ### 2. JSP中的Java脚本 #### 2.1 Java脚本代码块 在`<% ... %>`, `和 `%>`之间可以编写...
SSH(Struts2 + Spring + Hibernate)是一种常见的Java Web开发框架组合,用于构建高效、可扩展的Web应用程序。Struts2提供了MVC(Model-View-Controller)设计模式的实现,Spring提供了依赖注入(DI)和面向切面...
在Windows应用程序开发中,Microsoft Foundation Class (MFC)库提供了一种高效且便捷的方式来构建用户界面。本项目“mytest.rar”重点展示了如何利用MFC实现Ribbon风格的界面,并在该界面中添加状态栏来展示信息,...