2008
(无标题)
这几天做项目忙啊,饭都顾不上吃了。用JSP+Struts制作管理系统,技术上没有什么大问题,但细节优化上还比较难解决。
星期天,我老爸来了,带了些衣服之类的。晚上回去,还要做7、8个小时的车。看到老爸缓慢的背影,几根发白的头发,心里有些说不出的滋味,爸爸不容易啊,泪光~~~
这几天做项目忙啊,饭都顾不上吃了。用JSP+Struts制作管理系统,技术上没有什么大问题,但细节优化上还比较难解决。
星期天,我老爸来了,带了些衣服之类的。晚上回去,还要做7、8个小时的车。看到老爸缓慢的背影,几根发白的头发,心里有些说不出的滋味,爸爸不容易啊,泪光~~~
一个免费的、分布式的图片润饰、图象制作和处理软件,内含几乎所有图象处理所需的功能。GIMP在Linux系统推出时就风靡了许多绘图爱好者的喜爱,它的接口相当轻巧,但其功能却不输于专业的绘图软件;它提供了各种的影像处理工具、滤镜,还有许多的组件模块,对于要制作一个又酷又炫的网页按钮或网站Logo来说是一个非常方便好用的绘图软件。 Windows版本出来了。。。
如果您一直以为免费只是小软件才玩的把戏可就大错特错了,因为一些大型软件也同样能够找到免费的“替身”,比如这款GIMP就是其中一例,它要挑战的对象正是大名鼎鼎的 —— Photoshop。 个人感觉还是不错,推荐给大家!
The GIMP 2.6.1 (有中文,最新版才15M) 下载地址:http://www.skycn.com/soft/13201.html

首先,封装数据库操作,目的就是为了隐藏Java.sql包内的类,在编码中去掉核心的数据库操作代码。以杜绝直接数据库操作轻易带来的资源未释放问题。同时也减少了数据库操作的编码量。下面给大家一个简单的例子:
1、先用Bean来封装数据库操作
import Java.sql.*;
public class sql_data
{
//声明变量
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver"; //数据库驱动
String sConnStr="jdbc:odbc:book"; //使用桥对数据库连接
Connection conn=null;
ResultSet rs=null;
//加载驱动
public void sql_data()
{
try{
class.forName(sDBDriver);
}
catch(Java.lang.ClassNotFoundException e)
{
System.err.println(e.getMessage());
}
}
//数据插入
public void executeInsert(String sql)
{
try
{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println(ex.getMessage());
}
}
//数据查询
public ResultSet executeQuery(String sql)
{
rs=null;
try
{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex)
{
System.err.println(ex.getMessage());
}
}
//数据删除
public void executeDelete(String sql)
{
try
{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println(ex.getMessage());
}
}
}
2、在JSP页面中调用Bean:
……
<jsp:useBean id="sqlbean" class="book.sql_data"/> <!-- 调用Bean的数据封装类 -->
<%!String sql,name;%>
<%
sqlbean.sql_data(); //连接数据库
sql="select * from table";
ResultSet rs=sqlbean.executeQuery(sql);
while(rs.next()){
name=rs.getString("name");
%>
……
name1:<%=name%> name2: <%=rs.getString("name")%>
……
<%
}
rs.close();
%>
JavaEye JavaEye是一个以讨论Java技术和Hibernate技术开始的技术论坛
郁闷,刚才写了蛮长的一篇心情,可是不小心弄掉了!~~哎···
现在想要重新,不太容易了。深夜平静的让人感触蛮多。想想最近一段时间发生的一切,也许我真的该好好总结~``工作上的压力不算什么,有压力才有动力。至于感情~~··真的不好说,计划永远敢不上变化,顺其自然最好。。。干嘛不开心一点儿。其实幸福是很简单的,把自己放轻松点,给自己多一点的空间考虑,一切都可以OK~的~!
明天是做项目的第一天,不管怎么样。一定得有信心才是。
好长的一大堆的,也没分个段,眼睛都看花,真无语。摘抄几段来吧,留个影子。。。
“人在社会不仅仅要的是享受,还要的是奉献,在以后的日子里我们会想很多.但重要的是我们要有颗积极的心,对我们好的人好,想我们的人.一辈子是为了什么呢?是为了自己和家人活得更好的前提下,能为别人做点事,我不喜欢虚伪.我觉得是怎样就怎样.说实在的我觉得我失去了几个好朋友,这是我自己的错,以前我们很经常玩,但现在很少了,有时不是我想就能如愿的.不过只要他们幸福就可以了,毕竟在的环境和生活不同,也很难去强求,只希望快乐能伴随着。”
“今年懂了很多,有时还会疯疯颠颠的,有时很安静,我觉得我天生就是安静与疯的结合,现在很想写东西,以前特恼火,不知道是人长大了,还是怎的,有时还不写就不舒服了。不过现在喜欢上导游了,以前他们都说导游很会骗人,十足的骗子,现在觉得只要自己用心,我想没什么很困难的事情,有颗心就可以了.在自己快乐时,把这份爱给别人,不是有句话吗?”
“什么人都不会和微笑的人计较的,我想错误是会有的.只要我能改,我相信我能做好的,什么事情都不是绝对的,只要自己有心,对于金钱,我想没必要去想得太多,要那么多的钱自己不快乐也是空的,有就有,没有就没有,没有就要想着怎样去实现有的目标,而不是借着贷款先用在还, 但对于投资我会支持,我想人总要有自己的爱好.自己去追求吧,那这一辈子也不枉了,所以呢,呵呵想干就干 不要去多想,只要自己不后悔,就是做一辈子的房奴也没关系,呵呵反正那也只是我的想法,我不可能要求别人去怎样去做,喜欢就是喜欢,错过就是错过”
“以前有一种想法就是和我恋爱的第一个人结婚,好好的爱他一辈子,后来想想这是不可能的,但我想等我找到了我爱的人,和爱我的人,我会的,会好好的和他在一起,现在觉得很难找到那种永恒的爱吧。我说的可是事实哈,你看啦,那么多人,天天换男朋友和女朋友,那样本来就很没意思,是我/我就选择不要,对吧,有什么好呢,寂寞也不是这样哈,很看不起的哈,爱就要全心全意,除非是对方先放弃自己,那就两个人没缘分,我想就是只要自己对得起别人就可以,做到问心无愧就可以了,其他的也不重要的,轻松就好”
这两天下午玩的找不着北,就是心里矛盾啊。
离开学校也有几个月了
在秋日的阳光下,又再一次回味着曾经宁静而又向往的校园生活,能感觉校园的点滴就很欣慰了。
对于爱情:我不会爱、不懂得爱、也不值得爱。我是一个稻草人,每天看天亮看日落,就算全界都笑我,我还是我。
记得一个朋友,在星沙工作....很久了,她都好像忘记我了,从来都很少给我电话..每次都是我主动,那天见面我发现...她变了..真的变了.简直换了个人,这不是以前的她,以前的她很节制,吃东西买东西从不挑检,现在完全相反,也变得会享受多了,可能这样也是一种好吧,一种成熟标志吧。 环境真的很容易改变一个人..而我..什么时候才会变.. 也许这些都是被生活逼出来的吧~
每个人都为生活奔波劳碌,生活仍然缺乏目标、缺少激情,平淡不是不好,太过平淡或者就不好,没有愤怒没有兴奋,只有偶尔的彷徨和无奈,更多的时候是大段的沉默和发呆。每个人都有自己的道路要走,每个人要走的路也不同,要为自己过去的错误负责,更要为自己未知的将来做出努力!
喜欢记录,记录自己生活中的每一步,虽然看似是小事,却又是重要的。如果可以,我只是希望自己能够沒有担忧的生活,一切都是那么简单、随和、自然。
分页每个项目里面差不多都会用到
我以前耶找了很多个,刚刚找到一个很好用的分页 (baallynn )
先是一个page的bean:
package com.leatherstore.other;
public class Page {
/** 是否有上一页 */
private boolean hasPrePage;
/** 是否有下一页 */
private boolean hasNextPage;
/** 每页的数量 */
private int everyPage;
/** 总页数 */
private int totalPage;
/** 当前页*/
private int currentPage;
/** 起始点 */
private int beginIndex;
/** 总记录数*/
private int totalCount;
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public Page(){
}
public Page(int everyPage){
this.everyPage = everyPage;
}
public Page(boolean hasPrePage, boolean hasNextPage,
int everyPage, int totalPage,
int currentPage, int beginIndex,int totalCount) {
this.hasPrePage = hasPrePage;
this.hasNextPage = hasNextPage;
this.everyPage = everyPage;
this.totalPage = totalPage;
this.currentPage = currentPage;
this.beginIndex = beginIndex;
this.totalCount = totalCount;
}
public int getBeginIndex() {
return beginIndex;
}
public void setBeginIndex(int beginIndex) {
this.beginIndex = beginIndex;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getEveryPage() {
return everyPage;
}
public void setEveryPage(int everyPage) {
this.everyPage = everyPage;
}
public boolean getHasNextPage() {
return hasNextPage;
}
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
public boolean getHasPrePage() {
return hasPrePage;
}
public void setHasPrePage(boolean hasPrePage) {
this.hasPrePage = hasPrePage;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
}
然后构建一个page的工厂PageUtil:
package com.leatherstore.other;
public class PageUtil {
/**
* Use the origin page to create a new page
*
* @param page
* @param totalRecords
* @return
*/
public static Page createPage(Page page, int totalRecords) {
return createPage(page.getEveryPage(), page.getCurrentPage(),
totalRecords);
}
/**
* the basic page utils not including exception handler
*
* @param everyPage
* @param currentPage
* @param totalRecords
* @return page
*/
public static Page createPage(int everyPage, int currentPage,
int totalRecords) {
everyPage = getEveryPage(everyPage);
currentPage = getCurrentPage(currentPage);
int beginIndex = getBeginIndex(everyPage, currentPage);
int totalPage = getTotalPage(everyPage, totalRecords);
boolean hasNextPage = hasNextPage(currentPage, totalPage);
boolean hasPrePage = hasPrePage(currentPage);
return new Page(hasPrePage, hasNextPage, everyPage, totalPage,
currentPage, beginIndex, totalRecords);
}
private static int getEveryPage(int everyPage) {
return everyPage == 0 ? 10 : everyPage;
}
private static int getCurrentPage(int currentPage) {
return currentPage == 0 ? 1 : currentPage;
}
private static int getBeginIndex(int everyPage, int currentPage) {
return (currentPage - 1) * everyPage;
}
private static int getTotalPage(int everyPage, int totalRecords) {
int totalPage = 0;
if (totalRecords % everyPage == 0)
totalPage = totalRecords / everyPage;
else
totalPage = totalRecords / everyPage + 1;
return totalPage;
}
private static boolean hasPrePage(int currentPage) {
return currentPage == 1 ? false : true;
}
private static boolean hasNextPage(int currentPage, int totalPage) {
return currentPage == totalPage || totalPage == 0 ? false : true;
}
}
然后建一个专用的bean:
package com.leatherstore.hibernate.domain;
import java.util.List;
import com.leatherstore.other.Page;
public class Result {
private Page page; //分页信息
private List content; //每页显示的集合
public Result() {
super();
}
public Result(Page page, List content) {
this.page = page;
this.content = content;
}
public List getContent() {
return content;
}
public Page getPage() {
return page;
}
public void setContent(List content) {
this.content = content;
}
public void setPage(Page page) {
this.page = page;
}
}
然后在数据访问层写两个方法:
ProductDAO:
public List getProductByPage(Page page);
public int getProductCount(); //返回数据的总数
ProductDAO的接口实现ProductDAOImpl:
//为了在spring里统一编程风格:我用的回调的方法
public List getProductByPage(final Page page) {
return this.getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query=session.createQuery("from Productinfo");
query.setFirstResult(page.getBeginIndex()); //hibernate分页的精髓 呵呵
query.setMaxResults(page.getEveryPage());
return query.list();
}
});
}
public int getProductCount() {
List list=this.getHibernateTemplate().find("select count(*) from Productinfo");
return ((Integer)list.iterator().next()).intValue();
}
然后是业务层:
IProduct:
public Result listProduct(Page page);
然后IProduct接口的实现:IProductImpl:
private ProductDAO productDAO;
public void setProductDAO(ProductDAO productDAO){
this.productDAO=productDAO;
}
public Result listProduct(Page page) {
int totalRecords = this.productDAO.getProductCount();
page = PageUtil.createPage(page, totalRecords);
List products = this.productDAO.getProductByPage(page);
return new Result(page, products);
}
然后再代理层:
ProductProxy:
IProduct pro=(IProduct)AppContext.getInstance().getappcontext().getBean("productServicewithTran");
public Result productlist(Page page){
try{
return pro.listProduct(page);
}catch(DataAccessException ex){
ex.printStackTrace();
return null;
}
}
呵呵 终于到productAction啦
显示前方法的代码
Page page = new Page(); //实例化一个page对象
page.setEveryPage(10); //设置每页显示的条数
page.setCurrentPage(1); //为第一页
Result result = pdp.productlist(page);
request.setAttribute("page", pageinfo);
request.setAttribute("productlist", list);
return mapping.findForward("showProduct");
接着就是jsp页面了
<logic:iterate id="product" name="productlist">
//中间迭代所要显示的数据
</logic:iterate>
<tr>
<td width="80" height="30"> </td>
<logic:equal value="true" name="page" property="hasPrePage">
<td width="150" height="30"><div align="right"><a href="../product.do?method=showProductByTag&index=first&msg=${msg }">首页</a></div></td>
<td width="80" height="30"><div align="center"><a href="../product.do?method=showProductByTag&index=prew&pageno=${page.currentPage -1}&msg=${msg }">上一页</a></div></td>
</logic:equal>
<logic:notEqual value="true" name="page" property="hasPrePage">
<td width="150" height="30"><div align="right">首页</div></td>
<td width="80" height="30"><div align="center">上一页</div></td>
</logic:notEqual>
<logic:equal value="true" name="page" property="hasNextPage">
<td width="80" height="30"><div align="center"><a href="../product.do?method=showProductByTag&index=next&pageno=${page.currentPage +1 }&msg=${msg }">下一页</a></div></td>
<td width="80" height="30"><div align="center"><a href="../product.do?method=showProductByTag&index=end&pageno=${page.totalPage }&msg=${msg }">尾页</a></div></td>
</logic:equal>
<logic:notEqual value="true" name="page" property="hasNextPage">
<td width="80" height="30"><div align="center">下一页</div></td>
<td width="80" height="30"><div align="center">尾页</div></td>
</logic:notEqual>
<td height="30" colspan="3"><div align="center">页次${page.currentPage }/${page.totalPage } 共${page.totalCount }条记录</div> <div align="center"></div></td>
</tr>
可以显示相应的页面信息
然后productAction里面的showProductByTag代码如下:
Page page = new Page();
page.setEveryPage(10);
String pagemark = request.getParameter("goto");
if (pagemark == null) {
String state = request.getParameter("index");
String pageno = request.getParameter("pageno");
System.out.println("pageno=" + pageno);
if ("first".equals(state)) {
page.setCurrentPage(1);
Result result = pdp.productlist(page);
request.setAttribute("page", result.getPage());
request.setAttribute("productlist", result.getContent());
} else if ("prew".equals(state)) {
page.setCurrentPage(Integer.parseInt(pageno));
Result result = pdp.productlist(page);
request.setAttribute("page", result.getPage());
request.setAttribute("productlist", result.getContent());
} else if ("next".equals(state)) {
page.setCurrentPage(Integer.parseInt(pageno));
Result result = pdp.productlist(page);
request.setAttribute("page", result.getPage());
request.setAttribute("productlist", result.getContent());
} else if ("end".equals(state)) {
page.setCurrentPage(Integer.parseInt(pageno));
Result result = pdp.productlist(page);
request.setAttribute("page", result.getPage());
request.setAttribute("productlist", result.getContent());
}
} else {
page.setCurrentPage(Integer.parseInt(pagemark));
Result result = pdp.productlist(page);
request.setAttribute("page", result.getPage());
request.setAttribute("productlist", result.getContent());
}
return mapping.findForward("showProduct");
完了,大功告成了! 虽然代码多了点,但我觉得这样挺好的。
很久没有到这里来抒发下心情了。最近烦心事真多,手机啊,电脑啊,培训啊, 什么都倒霉,碰到鬼了。搞得我财务紧张.....鞋都买不起了。父母不容易啊,不敢向家里要钱了,还是自己看着办吧,不想让家里担心。
国庆七天的假期,似乎很快就过去了。通宵了三次。游玩了4天。说不出的感觉。梦一样。
10月4日,正是我的生日,从好久以前想法开始变了,不像以前总盼着过生日,只不过是又长了一岁老了一岁! 最后,还要感谢给我的礼物,很特别。