logo
  • Home
  • About
  • Archive
  • GuestBook
  • Feed Help
  • English

Tag for "Java"

eclipse小技巧之Quick Access(快速访问)

Saturday September 15, 2007

eclipse是我的主力开发工具,熟练掌握一些小技巧和快捷键可以起到事半功倍的作用,其中有一个tpis很吸引我,那就是Ctrl+3 Quick Access

我想很多经常用linux的人都习惯使用命令行来操作,我也不例外,而eclipse中的这个tips就给我这种感觉
quickaccess.png
Continue reading »

1 Comment »

高效程序开发人员应该有的7个习惯

Saturday September 8, 2007

Sun Microsystems亚太区的工程师Lee Chuk Munn写了一篇不错的小文,介绍一个高效程序开发人员的应该有的 7个习惯

1. 明白问题
2. 使用合适的工具
3. 保持简单,简易
4. 保持代码整洁
5. 学习调试
6. 借鉴他人
7. 持续学习

Keep it clean, and keep it simple–that is the maxim software developers should adhere to.

  • Understand the problem
  • For instance, Lee said, there are different algorithms engineers can use to write a sorting program.

    To select the right one to use, developers need to first understand the size of the data–that the sorting program will be administered on–in order to decide which is the right algorithm to use. “Choosing the wrong one would put your application in jeopardy in future,” he said.

  • Use appropriate tools
  • Quoting American psychologist Abraham Maslow, Lee read: “If the only tool you have is a hammer, you will see every problem as a nail.”

    This Maslow concept has become so popular among software developers that it has been dubbed the “Golden Hammer” rule, which cautions engineers with limited knowledge or training of solutions that they run the risk of using only tools they are familiar with, but that may not be the most appropriate, when they develop a new program.

Continue reading »

Add Comment »

关于finally中赋值

Sunday September 2, 2007

今天看到一个有意思的程序,写下来

public class FinallyTest {
	private static int test() {
		int i=1;
		try {
			i=2;
			return i;
		} catch (Exception e) {
			i = 3;
			return i;
		} finally {
			i = 4;
		}
	}
	public static void main(String[] args){
		FinallyTest finallyTest = new FinallyTest ();
		System.out.println("i=" + finallyTest.test());
	}
}

运行结果是

i=2

为什么呢,不是明明在finally中赋值了i=4吗?
答案是:
Continue reading »

Add Comment »

webwork学习笔记(二)之简单登录实现

Wednesday June 6, 2007

配置web.xml

< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.
//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web -app>
  <servlet>
  	</servlet><servlet -name>webwork</servlet>
  	<servlet -class>
com.opensymphony.webwork.dispatcher.ServletDispatcher
</servlet>
 
  <servlet -mapping>
  	</servlet><servlet -name>webwork</servlet>
  	<url -pattern>*.action</url>
 
  <taglib>
  	</taglib><taglib -uri>webwork</taglib>
  	<taglib -location>/WEB-INF/lib/webwork-2.1.7.jar</taglib>
 
  <resource -ref>
	<res -ref-name>jdb/sqlserver</res>
	<res -type>javax.sql.DataSource</res>
	<res -auth>Container</res>
</resource>
</web>

Continue reading »

2 Comments »

webwork学习笔记(一)

Tuesday June 5, 2007

webwork, 一 mvc 框架
所需基本类库,从官方 下载, 我采用 webwork2.1.7, 主要是为了配合 webwork in action 这本书
学习要点:
1. 所需类库:

commons-logging.jar ognl.jar oscore.jar velocity-dep.jar webwork-2.1.7.jar xwork.jar

2. action可选择implements Action,也可以选择extends ActionSupport,推荐采用后者,都要实现 execute这个方法,如:

public String execute() {
      if(name == null || "".equals(name) || "World".equals(name)){
	   addFieldError("name",
"Blank names or names of 'World' are not allowed!");
			return INPUT;
		}
		message = "hello, " + name + "!";
		message += "The time is:";
		message += mystring;
		return SUCCESS;
	}

Continue reading »

Add Comment »

将下拉列表框中的数据添加到文本框中

Wednesday May 23, 2007

下拉列表框中的数据是从字典表中取得的, 实现方法 在 这里
这次是采用js来实现的,代码如下

      function atSub()
{
    var index_s =document.add.test.selectedIndex;
    var content = document.add.test.options[index_s].value;
     document.add.member.value+= content + "   ";
}

页面代码如下

<tr>
<td class='small' width="14%" bgcolor="#D8EBF5">
   <div align="center">成员:</div>
</td>
<td colspan="3" bgcolor="#D8EBF5" class='small'>
<input type="text" name="member" id="member" size="76.5">
    <select style="width: 160; height: 23" 
        onChange="javascript:atSub();" name="test">
	<option value="">选择成员	</option>
		<%
                     Vector mm = UserInfo.getAllUsers();
                         for(int i=0;i<mm.size();i++){
                             UserInfo mmall = (UserInfo)mm.get(i);
		%>
		<option value="<%=mmall.getUserName()%>">
	                <%=mmall.getUserName()%>
		</option>
               <%}%>
    </select>
</td>
</tr>

1 Comment »

字典表与列表框的讨论

Thursday May 17, 2007

在最近的一个小系统里要加入一个功能,一个列表框,数据从数据库的字典表中取得,研究了一下,实现了,记录下
只显示一个字段的内容,我采用Vector来实现,代码如下

package com.xx.work.data;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
 
import com.aheadsoft.work.dao.DBConnect;
 
public class Add {
	private int ID;
	private String workType;
	public int getID() {
		return ID;
	}
	public void setID(int id) {
		ID = id;
	}
	public String getWorkType() {
		return workType;
	}
	public void setWorkType(String workType) {
		this.workType = workType;
	}
	public Add(){
		ID = 0;
		workType = "";
	}
	public Add(int ID, String workType){
		this.ID = ID;
		this.workType = workType;
	}
	public void setID(String newID) {
		if (newID != null)
			this.ID = Integer.parseInt(newID);
	}
	public static Vector  excute() throws Exception{
		Vector list = new Vector();
		String Str = "select * from workType";
		DBConnect dbc = null;
		ResultSet rs = null;
		try {
			dbc = new DBConnect();
			try{
				rs = dbc.executeQuery(Str);
				while (rs.next()) {
					Add add = new Add();
					add.setWorkType(rs.getString("workType"));
					list.add(add);
				}
			}catch(SQLException e){
				e.printStackTrace();
			}finally{
				if(rs != null)
					rs.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			if(dbc !=  null)
				dbc.close();
		}
		return list;
	}
	public static void main(String [] args){
	}
}

Continue reading »

2 Comments »

tomcat5.5.23中access连接池的配置方法

Thursday May 17, 2007

记录一下, 这里只给出server.xml的配置方法,其它的配置及测试代码在 这里

<logger className="org.apache.catalina.logger.FileLogger"
            directory="logs"  prefix="localhost_log." suffix=".txt"
            timestamp="true"/>
         <context docBase="cmmi" path="/cmmi" 
                 reloadable="true" crossContext="true">
	    <logger className="org.apache.catalina.logger.FileLogger"
                     prefix="localhost_lovehome_log." 
                     suffix=".txt" timestamp="true"/>
       <resource name="jdbc/access" auth="Container" 
              type="javax.sql.DataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
              username="sa" password="12345"
              url="jdbc:odbc:work"
              defaultAutoCommit="true" removeAbondoned="true"
              removeAbondonedTimeout="60" logAbondoned="true"/>
        </context>

Add Comment »

Page 1 of 212»
  • Feedburner
  • Feedsky
  • flickr Photos

    梅江河畔, 好像有人经常在这洗菜站在一座叫宁北大桥的桥上拍梅江河这是啥东东
  • Latest Posts

    • 新年快乐
    • 25 Fresh, Clean and Unique Wordpress Themes
    • WordPress Theme: Zexee
    • 正式更换博客域名为 roamlog.info
    • 2010, 新年快乐!
    • 100 Premium Like But Free, Fresh Wordpress Themes: Year 2009
    • Wordpress Theme:Lifedit
    • 40 个高质量且免费的 WordPress 主题
    • Glassical: A Free WordPress Theme
    • Modern Blue Dark WordPress Theme

© 2007 - 2010 漫步, designed by roamlog, hosted by wfans.org Valid XHTML CSS | 赣ICP备07002199