Struts Message Resources
The MessageResources class allows a developer to easily support multiple languages, in addition to supporting multiple date and numeric formats. Another useful trait is that properly using resource bundles will allow the developer to store label strings in a centralized location, without having to duplicate the same string throughout your JSP code. For example, instead of having the string “First Name” in each form with a field for the user’s first name, you can simply refer to this property
配置IDEA和STRUTS
1,下载Struts 插件(安装Struts Assistant),在Resource直接update,注意设置代理或者防火墙,安装完成后重启IDEA,控制面板会出现Struts Assistant。2,下载struts,譬如struts-1.2.8,解压之。点击Struts Assistant,设置"Struts distributive",目录指向Struts解压后的根目录。打开工程中的struts-config.xml文件,这样可以在左边的struts assistant的panel里看到你的form和action等。3,映射标签,在esource里做一下映射,譬如/struts-bean 对应E:/Server/frame_work/struts-1.2.8/contrib/struts-el/lib/struts-bean.tld,在web
JDom读写XML(代码)
SAXBuilder builder; Document doc; Element root; public ConfigOperater() { builder = new SAXBuilder(); try { doc = builder.build(DataUtil.CONFIG_PATH); root = doc.getRootElement(); } catch (IOException ex) { ex.printStackTrace(); } catch (JDOMException ex) { ex.printStackTrace(); } } //JDom读取XML public void readConfig() { List allConfigDB = root.getChildren("TargetDB&quo
[IDEA]习惯用的idea快捷方法
1. 打开类文件: Ctrl + N2. 打开非类文件: Ctrl + Shift + N3. 显示类或方法的javadoc: Ctrl + Q4. 找到类,方法,变量的声明的地方: Ctrl + B5. 快速展示类的元素: Ctrl + F126. 覆盖基类方法: Ctrl + O7. 实现接口或抽象类的方法: Ctrl + I8. 为了完成code completetion, 我们可以使用tab(和enter键有所区别)键完成所选项9. 向类中插入getter, setter方法: Alt + Insert10. 在任何view中快速选择元素: Alt + F111. 在view中的speed search: 直接输入文字即可12. 在任何tool窗口中使用Escape键,将焦点转到editor上.Shift+Escape移动焦点到
Java界面编程
1,Jtable加到JScroll中,默认只实现了垂直滚动(VERTICAL),而水平滚动(Horizontal)没有实现,这时候会使得无论格子数量,总长度=界面宽度。解决:jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 2,Swing常常显示中文乱码,对于使用了UIManager.getSystemLookAndFeelClassName() 的程序,可以采用如下方法;解决:在UIManager.getSystemLookAndFeelClassName() 下方添加代码java.util.Enumeration enum = UIManager.getDefaults().keys();String str;while(enum.hasMoreElements()){ if((str = (String)enum.nextElement()).
SWing事件调用
1,事件响应: testButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ JButton source = (JButton)e.getSource(); source.setText("ok"); } }); 2,回调 ButtonAction action = new ButtonAction(); action.putValue(AbstractAction.NAME,"action"); testButton.setAction(action); ............................. ......................... class ButtonAction extends Ab
jar的使用
1,创建jarjar -cf myjar.jar ./classes 2,详细输出jar -cvf myjar.jar ./classes 3,查看jar包jar -tf myjar.jar 4,解开jar xf myjar.jar 5,仅解开classesMain.classjar xf myjar.jar Main.class classesMain.class 6,更新jar uvf myjar.jar classes/Main.class 7,打包执行的方法jar cvfm test.jar manifest.mf test 此处manifest.mf 必须格式正确,一行最后不要有空格,最后一行置空jar -jar test.jar [@more@]
一个JTextPane写SQL语句的问题
在JTextArea或者JTextPanel中写下如下SQL语句--sekectselect * from users则执行类接受到SQL,执行结果:报错“缺少法定参数”。 百思不得其解,所以提出这个问题 折衷解决写了转换方法,该方法取消" "," "取代之,取消-注释的语句。 public static String getFormatedSqlStr(String sqlStr){ int endPos,notePos; while((endPos=sqlStr.indexOf(" "))>=0){ //匹配每一行 if ((notePos = sqlStr.indexOf("--")) >= 0 && endPos > notePos ){ //e
JComboBox 的长度调节问题
JComboBox 的宽度调节非常棘手 解决方法是将其加入JScroPanel,任其自由伸缩[@more@]
JBuilder7 问题
1,光标问题解决方式tools->Editor->options->Color,将Screen element列表中所有的条目的bold选项去掉。这种方法可以保持现有字体,比较漂亮 或者更换字体为新宋体等,改变大小为13。 2,鼠标滚轮找到JBuilder7injdk.config文件,将javapath和addpath两行修改,例如:# javapath ../jdk1.3.1/jre/bin/hotspot/jvm.dlljavapath E:/Server/j2sdk/jre/bin/server/jvm.dll# addpath ../jdk1.3.1/lib/tools.jaraddpath E:/Server/j2sdk/lib/tools.jar当然有更加优雅的解决方式:下载jbWheel090.zip,置于..JBuilder7libext下重启,
对Join的理解
在线程中,Join用于等待一个线程的结束。从线程调度的角度来说,就是把调用该方法的当前进程置于线程链顶端,当前进程执行结束,其余进程开始执行。 Join是同步线程的一种方法,另种方法是wait()以及notify(). 以下举一个例子说明Join的作用。 class ThreadJoinTest { public static void main(String[] args) throws InterruptedException{ TestTmp test1 = new TestTmp(); TestTmp test2 = new TestTmp(); TestTmp test3 = new TestTmp(); test1.join(); // join test2.join(); // joi
Struts必要的环境
对于Struts工程,有些必要的文件必须包含WEB-INF/LIB : commons-beanutils.jar commons-collections.jar commons-logging.jar commons-validator.jar struts.jarWEB-INF: struts-bean.tld struts-html.tld struts-logic.tld web.xml(这个是通用必须的) struts-config.xml app.tld(对于自定义的标签)WEB-INF/classes ApplicationResources.properties (对于必要的属性,可以自己添加,该文件必须建立在适当的路径下,跟Java包文件相关)对于引用这些TLD,可以建立一个taglib.j
使用ant编译Java文件(一)
首先实现一个简单的过程 必要的准备,下载ant1.5.2,解压,将bin目录置于环境变量的path中1,建立目录 ant_test2,建立目录 ant_testsrc,ant_testsrcoata3,建立 Java文件HelloWorld.javapackage oata;public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); }}4,建立配置文件build.xml<project name="HelloWorld" default="compile" basedir="."> <target name="clean"> <delete dir="build&
使用ant编译Java文件(二)
第二部分主要涉及到配置文件的依赖设置以及jar包的引入 1,下载log4j.jar,置于ant_testlib目录下 2,程序修改为package oata; import org.apache.log4j.Logger; import org.apache.log4j.BasicConfigurator; public class HelloWorld { static Logger logger = Logger.getLogger(HelloWorld.class); public static void main(String[] args) { BasicConfigurator.configure(); logger.info("Hello World"); // the old SysO-statement } } 3,build.xml修改为<projec
Tutorial: Hello World with Ant(转,来自apache)
This document provides a step by step tutorial for starting java programming with Ant. It does not contain deeper knowledge about Java or Ant. This tutorial has the goal to let you see, how to do the easiest steps in Ant.ContentPreparing the project Enhance the build file Enhance the build file Using external libraries Resources Preparing the projectWe want to separate the source from the generated files, so our java source files will be in src folder. All generated files should be under build,
Resin2.1.6配置Hibernate解析XML出错的解决
近日在Resin2.1.6上配置hibernate,执行时出现如下bug: 从报错信息中看(如图标出的部分),原因是resin采用的xml解析器,不支持对hibernate.cfg.xml的解析。 查到resin的官方文档上有一篇文章,对resin改变默认xml解析器写出了过程,其中用到的xml解析器是apache的Xerces。 对照文档,对resin.conf的项目配置部分作出如下修改: <web-app id="chapter4" app-dir="F:workjava_studyhibernatechapter4" > <!-- xml --> <system-property javax.xml.parsers.DocumentBuilderFactory= &quo