SpringSide是个什么东西呢?这么说吧,就是“采众家之长”的一个一站式框架,它吸取了开源界许多优秀组件的精华部分,非常简约的一个东西,具体就不多介绍了,自己可以参考官方文档。
下面来看看运用这个框架实现一个简单的用户管理究竟有多么容易。
先来看表现层:
新增或修改用户页面:

 <%
<% @ page contentType="text/html;charset=UTF-8" %>
@ page contentType="text/html;charset=UTF-8" %>
 <%
<% @ include file="/commons/taglibs.jsp" %>
@ include file="/commons/taglibs.jsp" %> <html>
<html> <head>
<head>
 <%
    <% @ include file="/commons/meta.jsp" %>
@ include file="/commons/meta.jsp" %> <title>User Manage</title>
    <title>User Manage</title> </head>
</head>
 <body>
<body> <div id="page">
<div id="page"> <div id="header">
    <div id="header"> <h1>Helloworld Sample</h1>
        <h1>Helloworld Sample</h1> </div>
    </div>
 <%
    <% @ include file="/commons/messages.jsp" %>
@ include file="/commons/messages.jsp" %> <div id="content">
    <div id="content"> <h1>User Infomation Manage</h1>
        <h1>User Infomation Manage</h1> <html:form action="/user.do" focus="name" styleClass="form" onsubmit="return validateUserForm(this)">
        <html:form action="/user.do" focus="name" styleClass="form" onsubmit="return validateUserForm(this)"> <input type="hidden" name="method" value="save"/>
            <input type="hidden" name="method" value="save"/> <html:hidden property="id"/>
            <html:hidden property="id"/> <table>
            <table> <tr>
                <tr> <td><label>Name</label></td>
                    <td><label>Name</label></td> <td>
                    <td> <html:text property="name" styleClass="text"/>
                        <html:text property="name" styleClass="text"/> <span class="req">*</span>
                        <span class="req">*</span> <span class="fieldError"><html:errors property="name"/></span>
                        <span class="fieldError"><html:errors property="name"/></span> </td>
                    </td> </tr>
                </tr> <tr>
                <tr> <td><label>EMail</label></td>
                    <td><label>EMail</label></td> <td>
                    <td> <html:text property="email" styleClass="text"/>
                        <html:text property="email" styleClass="text"/> </td>
                    </td> </tr>
                </tr> <tr>
                <tr> <td><label>Remark</label></td>
                    <td><label>Remark</label></td> <td>
                    <td> <html:textarea property="descn" rows="10" cols="40"/>
                        <html:textarea property="descn" rows="10" cols="40"/> </td>
                    </td> </tr>
                </tr> </table>
            </table> <div>
            <div> <html:submit property="saveBtn" styleClass="button">Save</html:submit>
                <html:submit property="saveBtn" styleClass="button">Save</html:submit> <html:cancel styleClass="button">Cancel</html:cancel>
                <html:cancel styleClass="button">Cancel</html:cancel> </div>
            </div> </html:form>
        </html:form> </div>
    </div> </div>
</div> <html:javascript formName="userForm" staticJavascript="false" dynamicJavascript="true" cdata="false"/>
<html:javascript formName="userForm" staticJavascript="false" dynamicJavascript="true" cdata="false"/> <script type="text/javascript" src="${ctx}/scripts/validator.jsp"></script>
<script type="text/javascript" src="${ctx}/scripts/validator.jsp"></script>
 <%
<% @ include file="/commons/footer.jsp" %>
@ include file="/commons/footer.jsp" %> </body>
</body> </html>
</html>
用户列表页面:

 <%
<% @ page contentType="text/html;charset=UTF-8" %>
@ page contentType="text/html;charset=UTF-8" %>
 <%
<% @ include file="/commons/taglibs.jsp" %>
@ include file="/commons/taglibs.jsp" %> <html>
<html> <head>
<head>
 <%
    <% @ include file="/commons/meta.jsp" %>
@ include file="/commons/meta.jsp" %> <link href="${ctx}/widgets/extremecomponents/extremecomponents.css" type="text/css" rel="stylesheet">
    <link href="${ctx}/widgets/extremecomponents/extremecomponents.css" type="text/css" rel="stylesheet"> <title>User Manage</title>
    <title>User Manage</title> </head>
</head>
 <body>
<body> <div id="page">
<div id="page"> <div id="header">
    <div id="header"> <h1>Helloworld Sample</h1>
        <h1>Helloworld Sample</h1> </div>
    </div>
 <div id="content">
    <div id="content"> <h1>User List</h1>
        <h1>User List</h1>
 <%
        <% @ include file="/commons/messages.jsp" %>
@ include file="/commons/messages.jsp" %> <ec:table items="users" var="user"
        <ec:table items="users" var="user" action="${ctx}/user.do">
                  action="${ctx}/user.do"> <ec:exportXls fileName="UserList.xls" tooltip="Export Excel"/>
            <ec:exportXls fileName="UserList.xls" tooltip="Export Excel"/> <ec:row>
            <ec:row> <ec:column property="rowcount" cell="rowCount" sortable="false" title="No." width="60"/>
                <ec:column property="rowcount" cell="rowCount" sortable="false" title="No." width="60"/> <ec:column property="id" title="ID" width="60"/>
                <ec:column property="id" title="ID" width="60"/> <ec:column property="name" title="Name" width="120"/>
                <ec:column property="name" title="Name" width="120"/> <ec:column property="email" title="Email" width="120"/>
                <ec:column property="email" title="Email" width="120"/> <ec:column property="descn" title="Description" viewsDenied="html"/>
                <ec:column property="descn" title="Description" viewsDenied="html"/> <ec:column property="null" title="Edit" width="40" sortable="false" viewsAllowed="html">
                <ec:column property="null" title="Edit" width="40" sortable="false" viewsAllowed="html"> <a href="user.do?method=edit&id=${user.id}">Edit</a>
                    <a href="user.do?method=edit&id=${user.id}">Edit</a> </ec:column>
                </ec:column> <ec:column property="null" title="Remove" width="40" sortable="false" viewsAllowed="html">
                <ec:column property="null" title="Remove" width="40" sortable="false" viewsAllowed="html"> <a href="user.do?method=delete&id=${user.id}">Delete</a>
                    <a href="user.do?method=delete&id=${user.id}">Delete</a> </ec:column>
                </ec:column> </ec:row>
            </ec:row> </ec:table>
        </ec:table> </div>
    </div>
 <div>
    <div> <button id="addbtn" onclick="location.href='user.do?method=create'">Add</button>
        <button id="addbtn" onclick="location.href='user.do?method=create'">Add</button> </div>
    </div> </div>
</div>
 <%
<% @ include file="/commons/footer.jsp" %>
@ include file="/commons/footer.jsp" %> </body>
</body> </html>
</html>
对应的控制器类UserAction.java:
 package org.springside.helloworld.web;
package org.springside.helloworld.web;
 import org.springside.core.web.StrutsEntityAction;
import org.springside.core.web.StrutsEntityAction; import org.springside.helloworld.model.User;
import org.springside.helloworld.model.User; import org.springside.helloworld.service.UserManager;
import org.springside.helloworld.service.UserManager;

 /** *//**
/** *//** * 用户管理Controller.
 * 用户管理Controller. * <p/>
 * <p/> * 继承于StrutsEntityAction,不需编码就拥有默认的对User对象的CRUD响应函数. 如果想了解不继承于EntityAction,自行编写CRUD的写法, 参考{@link UserActionNativeVersion}.
 * 继承于StrutsEntityAction,不需编码就拥有默认的对User对象的CRUD响应函数. 如果想了解不继承于EntityAction,自行编写CRUD的写法, 参考{@link UserActionNativeVersion}. *
 * * @author calvin
 * @author calvin * @see org.springside.core.web.StrutsEntityAction
 * @see org.springside.core.web.StrutsEntityAction * @see org.springside.core.web.StrutsAction
 * @see org.springside.core.web.StrutsAction * @see UserActionNativeVersion
 * @see UserActionNativeVersion */
 */
 public class UserAction extends StrutsEntityAction<User, UserManager>
public class UserAction extends StrutsEntityAction<User, UserManager>  {
{
 @SuppressWarnings("unused")
    @SuppressWarnings("unused") private UserManager userManager;
    private UserManager userManager;

 public void setUserManager(UserManager userManager)
    public void setUserManager(UserManager userManager)  {
{ this.userManager = userManager;
        this.userManager = userManager; }
    } }
}
然后是业务逻辑层,
 package org.springside.helloworld.service;
package org.springside.helloworld.service;
 import org.springside.core.dao.HibernateEntityDao;
import org.springside.core.dao.HibernateEntityDao; import org.springside.helloworld.model.User;
import org.springside.helloworld.model.User;

 /** *//**
/** *//** * 用户管理业务类.
 * 用户管理业务类. * <p/>
 * <p/> * 继承于HibernateEntityDao,不需任何代码即拥有默认的对User对象的CRUD函数. 如果想了解不继承于EntityDao,自行编写CRUD的写法, 参考{@link UserManagerNativeVersion}.
 * 继承于HibernateEntityDao,不需任何代码即拥有默认的对User对象的CRUD函数. 如果想了解不继承于EntityDao,自行编写CRUD的写法, 参考{@link UserManagerNativeVersion}. *
 * * @author calvin
 * @author calvin * @see HibernateEntityDao
 * @see HibernateEntityDao * @see org.springside.core.dao.HibernateGenericDao
 * @see org.springside.core.dao.HibernateGenericDao * @see UserManagerNativeVersion
 * @see UserManagerNativeVersion */
 */
 public class UserManager extends HibernateEntityDao<User>
public class UserManager extends HibernateEntityDao<User>  {
{ //
    //  .CRUD以外的其它商业方法
.CRUD以外的其它商业方法 }
}
然后是模型层
 package org.springside.helloworld.model;
package org.springside.helloworld.model;
 import javax.persistence.Entity;
import javax.persistence.Entity; import javax.persistence.GeneratedValue;
import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;
import javax.persistence.GenerationType; import javax.persistence.Id;
import javax.persistence.Id; import javax.persistence.Table;
import javax.persistence.Table;

 /** *//**
/** *//** * 用户.带jpa annotation简版配置.
 * 用户.带jpa annotation简版配置. *
 * * @author calvin
 * @author calvin * @author schweigen
 * @author schweigen */
 */ //同USERS表映射
 //同USERS表映射 @Entity
@Entity @Table(name = "USERS")
@Table(name = "USERS") public class User
public class User 

 {
{ private Integer id;//用户id
    private Integer id;//用户id 
 private String name;//用户名
    private String name;//用户名
 private String email;//e-mail
    private String email;//e-mail
 private String descn;//自我介绍
    private String descn;//自我介绍
 //主键自动生成,其他,其余属性全部与数据库中的列默认映射。
    //主键自动生成,其他,其余属性全部与数据库中的列默认映射。 @Id
    @Id @GeneratedValue(strategy = GenerationType.AUTO)
    @GeneratedValue(strategy = GenerationType.AUTO)
 public Integer getId()
    public Integer getId()  {
{ return id;
        return id; }
    }

 public void setId(Integer id)
    public void setId(Integer id)  {
{ this.id = id;
        this.id = id; }
    }

 public String getName()
    public String getName()  {
{ return name;
        return name; }
    }

 public void setName(String name)
    public void setName(String name)  {
{ this.name = name;
        this.name = name; }
    }

 public String getEmail()
    public String getEmail()  {
{ return email;
        return email; }
    }

 public void setEmail(String email)
    public void setEmail(String email)  {
{ this.email = email;
        this.email = email; }
    }

 public String getDescn()
    public String getDescn()  {
{ return descn;
        return descn; }
    }

 public void setDescn(String descn)
    public void setDescn(String descn)  {
{ this.descn = descn;
        this.descn = descn; }
    } }
}

那么代码部分就这些了,可以看到不需要我们自己去写重复的CRUD代码,仅仅从一些特定的基类继承下来就可以了,而Jdk新加入的泛型技术的运用更是如虎添翼。那么对于配置文件部分,我个人感觉比以前好像更加复杂了呢,也许是还不习惯吧。。。