日韩1区2区日韩1区2区,国产精品区免费视频,亚洲久久久久http://www.aygfsteel.com/seesea/Java初學(xué)習(xí)zh-cnThu, 12 Jun 2025 18:17:52 GMTThu, 12 Jun 2025 18:17:52 GMT60Struts2學(xué)習(xí)http://www.aygfsteel.com/seesea/archive/2014/07/16/415883.htmlSeesSeaSeesSeaWed, 16 Jul 2014 02:47:00 GMThttp://www.aygfsteel.com/seesea/archive/2014/07/16/415883.htmlhttp://www.aygfsteel.com/seesea/comments/415883.htmlhttp://www.aygfsteel.com/seesea/archive/2014/07/16/415883.html#Feedback0http://www.aygfsteel.com/seesea/comments/commentRss/415883.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/415883.html
環(huán)境沒敢用最新的,MyEclipse用的是8.5的版本,Tomcat最終選擇了6,JDK也是用的7,Struts2的版本2.3.16.3。通常的配置沒什么要記錄的,主要記錄下出問題的地方:
1、Tomcat
從MyEclipse啟動(dòng)Tomcat一直報(bào)錯(cuò),后來下載了一個(gè)tcnative-1.dll文件才解決,版本要求比較嚴(yán)格,對(duì)于Tomcat6.0.41而言,這個(gè)動(dòng)態(tài)鏈接庫版本要求是1.1.30,1.1.3都不行,不知道有什么區(qū)別,將文件拷貝到j(luò)re/bin下即可。
2、web.xml文件內(nèi)容
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 3 
 4     <display-name>Struts Test</display-name>
 5 
 6     <filter>
 7         <filter-name>struts2</filter-name>
 8         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
 9     </filter>
10 
11     <filter-mapping>
12         <filter-name>struts2</filter-name>
13         <url-pattern>/*</url-pattern>
14     </filter-mapping>
15 
16     <welcome-file-list>
17         <welcome-file>index.html</welcome-file>
18     </welcome-file-list>
19 
20 </web-app>
21 
3、struts.xml文件內(nèi)容
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE struts PUBLIC
 3     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
 4     "http://struts.apache.org/dtds/struts-2.3.dtd">
 5 
 6 <struts>
 7 
 8    <constant name="struts.enable.DynamicMethodInvocation" value="true" />
 9     <constant name="struts.devMode" value="true" />
10 
11     <package name="default" namespace="/" extends="struts-default">
12 
13         <default-action-ref name="index" />
14 
15         <global-results>
16             <result name="error">/error.jsp</result>
17         </global-results>
18 
19         <global-exception-mappings>
20             <exception-mapping exception="java.lang.Exception" result="error"/>
21         </global-exception-mappings>
22         
23         <action name="action名" class="java包名及類名">
24         <result name="success">/調(diào)用的jsp頁面文件p</result>
25         </action>
26     </package>
27 
28     <include file="example.xml"/>
29 
30     <!-- Add packages here -->
31 
32 </struts>
33 
4、調(diào)用時(shí)發(fā)現(xiàn)action名定義了大小寫后,地址欄也要輸入相應(yīng)的大小寫,否則報(bào)錯(cuò)。這個(gè)問題困擾了好久。。。。。


By SeeSea


SeesSea 2014-07-16 10:47 發(fā)表評(píng)論
]]>
在ubuntu 8.04下安裝Oracle 11g方法http://www.aygfsteel.com/seesea/archive/2009/03/18/260400.htmlSeesSeaSeesSeaWed, 18 Mar 2009 02:52:00 GMThttp://www.aygfsteel.com/seesea/archive/2009/03/18/260400.htmlhttp://www.aygfsteel.com/seesea/comments/260400.htmlhttp://www.aygfsteel.com/seesea/archive/2009/03/18/260400.html#Feedback0http://www.aygfsteel.com/seesea/comments/commentRss/260400.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/260400.html項(xiàng)目要求使用Oracle,據(jù)說安裝方式比較繁復(fù),網(wǎng)上搜到兩篇文章,先備著,準(zhǔn)備日后按圖索驥。
第一篇
地址:http://forum.ubuntu.org.cn/viewtopic.php?f=44&t=136860

在ubuntu 8.04下安裝Oracle 11g
本文是參考了:http://hi.baidu.com/wuxicn/blog/item/0cfdc24ac5ae372609f7ef94.html"文章,是翻譯下面的這篇文章的。我主要參考的是中文的,我只是在實(shí)際操作中做了一點(diǎn)小小的修改,在此表示感謝!紫色為我的注釋。
原文是英文,地址是:
http://www.pythian.com/blogs/968/instal ... ardy-heron,(轉(zhuǎn)載注明出處,謝謝!! )
共9步:

Step 1
下載和安裝 Ubuntu 8.04 Hardy Heron (x86-32位) 版。略。

Step 2
下載Oracle 11g: Download Oracle 11g for Linux (x86, 32-bit).
現(xiàn)不要急著解壓,一會(huì)我會(huì)告訴你解壓在哪的。

Step 3
修改X server 的默認(rèn)設(shè)置,點(diǎn)菜單的System -> Administration -> Login Window(系統(tǒng)->管理->登錄窗口),選擇“Security(安全)”選項(xiàng)卡,取消“Deny TCP connections to the Xserver(拒絕TCP連接到X服務(wù)器)”的勾,重啟Xserver(或者重啟系統(tǒng))。然后在終端輸入:
user@hardy:~$ xhost +127.0.0.1
127.0.0.1 being added to access control list
Step 4
打開終端,轉(zhuǎn)換為超級(jí)用戶:(注意,這里用sudo su -而不是sudo -s是有原因的:sudo su - 將用戶轉(zhuǎn)換為超級(jí)用戶,并新起一個(gè)會(huì)話(空的會(huì)話),而不是像sudo -s那樣將當(dāng)前會(huì)話傳遞個(gè)新的超級(jí)用戶,減少環(huán)境變量可能造成的影響和危害。
user@hardy:~$ sudo su -
[sudo] password for user:
root@hardy:~# apt-get update
...
root@hardy:~# apt-get dist-upgrade
...
root@hardy:~# reboot
Step 5
用apt安裝一些必要的工具:

user@hardy:~$ sudo su -
[sudo] password for user:
root@hardy:~# apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm
...
root@hardy:~#
Step 6
在裝完那些工具以后,我們需要做的就是修改一些Ubuntu的/bin/sh的默認(rèn)連接,千萬不要略過這一步,否則安裝的時(shí)候會(huì)出現(xiàn)很多錯(cuò)誤。
root@hardy:~# cd /bin
root@hardy:/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-04-28 19:59 /bin/sh -> dash
root@hardy:/bin# ln -sf bash /bin/sh
root@hardy:/bin# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-05-01 22:51 /bin/sh -> bash
如果你想知道為什么Ubuntu用dash作為默認(rèn)的shell,看這個(gè):a detailed explanation of why dash is the default system shell 。
Step 7
增加用戶和組,并修改一些配置。這一步很重要!如果不是很有把握,不要隨便改。(為了便于解釋,增加了行號(hào)):
01 root@hardy:/bin# cd
02 root@hardy:~# pwd
/root
04 root@hardy:~# addgroup oinstall
Adding group `oinstall' (GID 1001) ...
Done.
07 root@hardy:~# addgroup dba
Adding group `dba' (GID 1002) ...
Done.
10 root@hardy:~# addgroup nobody
Adding group `nobody' (GID 1003) ...
Done.
13 root@hardy:~# usermod -g nobody nobody
14 root@hardy:~# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
15 root@hardy:~# mkdir /home/oracle
16 root@hardy:~# chown -R oracle:dba /home/oracle
17 root@hardy:~# ln -s /usr/bin/awk /bin/awk
18 root@hardy:~# ln -s /usr/bin/rpm /bin/rpm
19 root@hardy:~# ln -s /usr/bin/basename /bin/basename
20 root@hardy:~# mkdir /etc/rc.d
21 root@hardy:~# for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
22 root@hardy:~# mkdir -p /u01/app/oracle
23 root@hardy:~# chown -R oracle:dba /u01
24 root@hardy:~#
Lines 04-12: 增加我們需要的用戶和組
Line 13: 讓nobody用戶的組變?yōu)閚obody,這樣Oracle的安裝程序不會(huì)出問題。Ubuntu默認(rèn)nobody的組是nogroup。
Lines 14-18: 創(chuàng)建一個(gè)oracle用戶。注意,oracle用戶的HOME目錄不要與ORACLE_HOME相同。
Lines 19-23: 創(chuàng)建一些Oracle安裝程序需要的工具的連接。因?yàn)镺racle安裝程序是為Red Hat準(zhǔn)備的,所以有些工具的位置和Ubuntu不一樣。
Finally, on lines 24-25 創(chuàng)建ORACLE_BASE目錄。
Step 8
修改一些系統(tǒng)默認(rèn)值。這些修改將會(huì)增加系統(tǒng)文件描述符的數(shù)量、增加共享內(nèi)存大小和修改一些網(wǎng)絡(luò)子系統(tǒng)參數(shù)。這些修改是否會(huì)對(duì)你的系統(tǒng)帶來影響我就不得而知了。將下面這些增加到/etc/sysctl.conf文件的末尾:
fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
再增加下面這些到/etc/security/limits.conf文件末尾:

oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535
為了強(qiáng)制使用剛才我們?cè)黾拥臇|西,我們?cè)僭黾酉旅孢@些到/etc/pam.d/login文件末尾:

session required /lib/security/pam_limits.so
session required pam_limits.so
然后通過命令:sysctl -p 讓剛才增加的東西生效:

root@hardy:~# sysctl -p
kernel.printk = 4 4 1 7
kernel.maps_protect = 1
fs.inotify.max_user_watches = 524288
vm.mmap_min_addr = 65536
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
root@hardy:~#
Step 9
現(xiàn)在我們將剛才下載的oracle11g的安裝包解壓到/home/oracle/install/目錄下。然后進(jìn)入目錄,設(shè)置DISPLAY參數(shù),開始安裝:

root@hardy:~# cd /home/oracle
root@hardy:/home/oracle# chown -R oracle:dba install

用oracle用戶登陸,(不然會(huì)出安裝界面出不來)
oracle@hardy:~$ export DISPLAY=127.0.0.1:0.0
oracle@hardy:~$ pwd
/home/oracle
oracle@hardy:~$ ls -l
total 4
drwxr-xr-x 6 oracle dba 4096 2007-09-18 18:50 install
oracle@hardy:~$ cd install
oracle@hardy:~/install$ ls -l
total 28
drwxr-xr-x 11 oracle dba 4096 2007-08-06 16:02 doc
drwxr-xr-x 5 oracle dba 4096 2007-08-03 13:28 install
drwxr-xr-x 2 oracle dba 4096 2007-09-18 18:52 response
-rwxr-xr-x 1 oracle dba 2911 2007-08-03 13:28 runInstaller
drwxr-xr-x 14 oracle dba 4096 2007-08-03 13:27 stage
-rw-r--r-- 1 oracle dba 4835 2007-08-06 18:19 welcome.html
oracle@hardy:~/install$ ./runInstaller -ignoreSysPrereqs
輸入完上面命令后,就進(jìn)入了Oracle 的同一安裝程序了(OUI),不要急,繼續(xù)按照本文一步一步的通過安裝:
注意:OUI安裝完后,并不是真正完全安裝完成,還需要就行最后的收尾工作(在最后有),而且這是必須做的工作!


點(diǎn)(Next)下一步。


修改“Specify Operating System group name:”為:"dba",然后點(diǎn)"Next".


按照上圖設(shè)置,點(diǎn)下一步。


選擇"Enterprise Edition",然后下一步。


安圖設(shè)置,下一步。


繼續(xù)下一步。


等待系統(tǒng)檢查,不要擔(dān)心有錯(cuò)誤和警告。


將檢查到的所有非“Succeeded”的都打上勾,下一步。


,下一步。在這一步選"Create a Database"來安裝數(shù)據(jù)庫。([color=red]原文是通過netca建立監(jiān)聽,dbca建庫,我第一次也是這樣做的,dbca建庫時(shí)會(huì)報(bào)錯(cuò),因?yàn)閡butunbu 不支持RPM包)。[/color]

將所有組都設(shè)為:dba,下一步。

現(xiàn)在可以點(diǎn)“Install”了:)時(shí)間比較長。


到了這一步不要記著點(diǎn)“OK”,需要做下面操作:(另起一個(gè)終端,用sudo su - 轉(zhuǎn)為超級(jí)用戶)

root@hardy:~# /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory to 770.
Changing groupname of /u01/app/oraInventory to dba.
The execution of the script is complete
root@hardy:~# /u01/app/oracle/product/11.1.0/db_1/root.sh
Running Oracle 11g root.sh script...

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.1.0/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
root@hardy:~#
好了,這個(gè)完成后可以點(diǎn)“OK”了。
安后點(diǎn)“Exit”退出OUI,現(xiàn)在可以祝賀你,OUI安裝完成了:)但是還是不要急,記住咱們還有收尾工作需要做。
在/etc/profile文件中加入下面幾句:

export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export PATH=$PATH:/u01/app/oracle/product/11.1.0/db_1/bin
創(chuàng)建一個(gè)Oracle 11g數(shù)據(jù)庫的啟動(dòng)腳本,名字可以叫做:oracledb,在/u01/app/oracle/product/11.1.0/db_1/bin下建立文件:oracledb,內(nèi)容:

#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi

case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
touch /var/lock/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
rm -f /var/lock/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac

exit 0
修改腳本為可執(zhí)行的:

root@hardy:~# chmod a+x /u01/app/oracle/product/11.1.0/db_1/bin/oracledb
如果你希望開機(jī)自動(dòng)啟動(dòng)Oracle 11g數(shù)據(jù)庫,那么就作下面的工作:

root@hardy:~# ln -s /u01/app/oracle/product/11.1.0/db_1/bin/oracledb /etc/init.d/oracledb
root@hardy:~# sudo sysv-rc-conf --level 2345 oracledb on

如果沒有sysv-rc-conf命令,就apt-get一個(gè)。
最后,增加你自己的用戶名到dba組:

root@hardy:~# usermod -G dba -a user
好了,至此,Oracle 11g就安裝完了。重新登錄后,你就可以使用oracle的命令了。
(ORACLE_SID=orcl 是你安裝時(shí)候設(shè)置的值)

oracle@hardy:~$ export ORACLE_SID=orcl
oracle@hardy:~$ sqlplus '/as sysdba'

SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 5 02:39:27 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>connect /as sysdba
Connected to an idle instance.

SQL>startup 啟動(dòng)數(shù)據(jù)庫命令。
.
ORACLE instance started.



Total System Global Area 418484224 bytes

Fixed Size 1300324 bytes

Variable Size 281020572 bytes

Database Buffers 130023424 bytes

Redo Buffers 6139904 bytes

Database mounted.

Database opened.

oracle@hardy:~$ export ORACLE_SID=orcl
oracle@hardy:~$ emctl start dbconsole 啟動(dòng)EM,地址為https://yourip:1158/em/console.這樣你就可以通過IE登陸了。不過界面為亂碼。呵呵!!解決方法自己在網(wǎng)上找吧!!

如果你看到了上面的結(jié)果,證明你的oracle安裝成功了。

第二篇
地址:http://www.linuxidc.com/Linux/2008-06/13855.htm

花了半天時(shí)間,在Ubuntu 8.04 LTS上順利安裝Oracle 11G.下面說說大概的步驟.

1.確保安裝了以下程序:

sudo apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm

2.

cd /bin
ln -sf bash /bin/sh

 

3.增加用戶和組

addgroup oinstall
addgroup dba
addgroup nobody
useradd -g oinstall -G dba -p passwd -d /home/oracle -s /bin/bash oracle
usermod -g nobody nobody

4.
mkdir /home/oracle
chown -R oracle:dba /home/oracle

ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename

5.
mkdir /etc/rc.d
for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done

mkdir -p /opt/ora11
chown -R oracle:dba /opt

6.編輯/etc/sysctl.conf,增加以下內(nèi)容:

fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144

7.編輯/etc/security/limits.conf,增加以下內(nèi)容:

oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535

8.編輯/etc/pam.d/login,增加以下內(nèi)容:

session required /lib/security/pam_limits.so
session required pam_limits.so

9.執(zhí)行:

sysctl -p

10.

su - oracle

以上命令需以root用戶執(zhí)行,接下來切換至oracle用戶.

11.切換至安裝目錄,開始安裝.我選擇了英語作為安裝時(shí)顯示的語言.

export LANG=en_CN
./runInstaller

12.安裝過程中提示運(yùn)行以下兩個(gè)腳本:

orainstRoot.sh
root.sh

12.安裝過程中檢測到系統(tǒng)未裝有GLIBC環(huán)境,忽略后,未發(fā)現(xiàn)對(duì)安裝和運(yùn)行有多大影響.

13.切記,安裝時(shí)選擇自定義,并且選擇數(shù)據(jù)庫的字符集為 ZHS16GBK!

因?yàn)橥浟诉@個(gè)選項(xiàng),我只好刪掉數(shù)據(jù)庫,重新建了一個(gè),浪費(fèi)了半個(gè)小時(shí)的時(shí)間.

PS.ORACLE 11g好像不支持更改數(shù)據(jù)庫的字符集了...或是我沒有找到正確的方法

14.安裝完成后,數(shù)據(jù)庫的連接和查詢異常之慢,GOOGLE之,然后嘗試著把網(wǎng)絡(luò)的DNS服務(wù)器全給刪了,解決.

15.兩個(gè)常用的工具:dbca和netca.



 



SeesSea 2009-03-18 10:52 發(fā)表評(píng)論
]]>
Struts2 action 的 ;jsessionid=xxx 使找不到頁面 Bug 的解決 [轉(zhuǎn)帖]http://www.aygfsteel.com/seesea/archive/2008/08/12/221439.htmlSeesSeaSeesSeaTue, 12 Aug 2008 02:40:00 GMThttp://www.aygfsteel.com/seesea/archive/2008/08/12/221439.htmlhttp://www.aygfsteel.com/seesea/comments/221439.htmlhttp://www.aygfsteel.com/seesea/archive/2008/08/12/221439.html#Feedback0http://www.aygfsteel.com/seesea/comments/commentRss/221439.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/221439.html閱讀全文

SeesSea 2008-08-12 10:40 發(fā)表評(píng)論
]]>
Struts2設(shè)置http://www.aygfsteel.com/seesea/archive/2008/08/06/220459.htmlSeesSeaSeesSeaWed, 06 Aug 2008 08:27:00 GMThttp://www.aygfsteel.com/seesea/archive/2008/08/06/220459.htmlhttp://www.aygfsteel.com/seesea/comments/220459.htmlhttp://www.aygfsteel.com/seesea/archive/2008/08/06/220459.html#Feedback0http://www.aygfsteel.com/seesea/comments/commentRss/220459.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/220459.html 1、下載Struts2的jar包。下載地址:
http://struts.apache.org/2.0.9/index.html
2、解壓縮必要文件到項(xiàng)目中WebRoot\WEB-INF\lib下。灑家最開始引用的為:
commons-logging-1.0.4.jar
ognl-2.6.11.jar
xwork-2.0.4.jar
freemarker-2.3.8.jar
struts2-core-2.0.11.1.jar
3、修改項(xiàng)目中WebRoot\WEB-INF\web.xml文檔,增加如下內(nèi)容
<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> 
4、在項(xiàng)目中WebRoot/WEB-INF/classes下建立struts.xml文件。如果在MyEclipse中,可以直接建立在項(xiàng)目的src目錄中,MyEclipse將自動(dòng)將其拷貝到發(fā)布目錄的相關(guān)位置。文件內(nèi)容如下:
<?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="struts2" extends="struts-default">
    
<!--
    此處加入不同的action
    
-->
    
</package>
    
</struts>
   
5、建立jsp文件
如果使用struts的標(biāo)簽,則需要在jsp文件的第一行后插入:
<%@ taglib prefix="s" uri="/struts-tags" %>
暫時(shí)有事,回頭補(bǔ)充。



SeesSea 2008-08-06 16:27 發(fā)表評(píng)論
]]>
Ubuntu下的tomcat啟動(dòng)http://www.aygfsteel.com/seesea/archive/2008/08/01/219275.htmlSeesSeaSeesSeaFri, 01 Aug 2008 03:27:00 GMThttp://www.aygfsteel.com/seesea/archive/2008/08/01/219275.htmlhttp://www.aygfsteel.com/seesea/comments/219275.htmlhttp://www.aygfsteel.com/seesea/archive/2008/08/01/219275.html#Feedback0http://www.aygfsteel.com/seesea/comments/commentRss/219275.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/219275.html     還是喜歡ubuntu下的調(diào)試環(huán)境,所以還想選擇在這個(gè)下面開發(fā)。
    先在原有eclipse上安裝了MyEclipse,這次比較順利,記得上次安裝比較費(fèi)勁,總是啟動(dòng)不了,或許是因?yàn)檫@臺(tái)機(jī)器是inter的CPU緣故?不得而知。
    安裝TomCat遇到一些問題,主要是TomCat總是隨系統(tǒng)啟動(dòng),每次開機(jī)都需要手動(dòng)關(guān)閉服務(wù),比較麻煩。由于對(duì)ubuntu不熟悉,找了下方法,感覺比較好的方法如下:
安裝sysv-rc-conf
方法:
sudo apt-get install sysv-rc-conf
sudo sysv-rc-conf

這個(gè)工具可以調(diào)整啟動(dòng)項(xiàng)目,比較方便。




SeesSea 2008-08-01 11:27 發(fā)表評(píng)論
]]>
Eclipse發(fā)布程序http://www.aygfsteel.com/seesea/archive/2008/07/24/217213.htmlSeesSeaSeesSeaThu, 24 Jul 2008 08:19:00 GMThttp://www.aygfsteel.com/seesea/archive/2008/07/24/217213.htmlhttp://www.aygfsteel.com/seesea/comments/217213.htmlhttp://www.aygfsteel.com/seesea/archive/2008/07/24/217213.html#Feedback0http://www.aygfsteel.com/seesea/comments/commentRss/217213.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/217213.html 不過導(dǎo)出后遇到一些問題,就是第三方j(luò)ar文件錯(cuò)誤,這個(gè)找了一下,同樣在BlogJava上有人發(fā)表了方法,他推薦的是第一種方法,灑家用的是第二種。原文見http://www.aygfsteel.com/mimi-van/archive/2007/11/28/163597.html
為了自己閱讀方便,也粘貼一份吧。失敬,失敬!

我存檔的一篇java資料,里面對(duì) -jar 情況下的classpath 有了比較詳細(xì)的闡述。

當(dāng)用java -jar yourJarExe.jar來運(yùn)行一個(gè)經(jīng)過打包的應(yīng)用程序的時(shí)候,你會(huì)發(fā)現(xiàn)如何設(shè)置-classpath參數(shù)應(yīng)用程序都找不到相應(yīng)的第三方類,報(bào) ClassNotFound錯(cuò)誤。實(shí)際上這是由于當(dāng)使用-jar參數(shù)運(yùn)行的時(shí)候,java VM會(huì)屏蔽所有的外部classpath,而只以本身yourJarExe.jar的內(nèi)部class作為類的尋找范圍。

**解決方案**

一 BootStrap class擴(kuò)展方案

Java 命令行提供了如何擴(kuò)展bootStrap 級(jí)別class的簡單方法.
-Xbootclasspath:     完全取代基本核心的Java class 搜索路徑.
                                   不常用,否則要重新寫所有Java 核心class
-Xbootclasspath/a: 后綴在核心class搜索路徑后面.常用!!
-Xbootclasspath/p: 前綴在核心class搜索路徑前面.不常用,避免
                                   引起不必要的沖突.

語法如下:
 (分隔符與classpath參數(shù)類似,unix使用:號(hào),windows使用;號(hào),這里以u(píng)nix為例)
 java -Xbootclasspath/a:/usrhome/thirdlib.jar: -jar yourJarExe.jar

二 extend class 擴(kuò)展方案

Java exten class 存放在{Java_home}"jre"lib"ext目錄下.當(dāng)調(diào)用Java時(shí),對(duì)擴(kuò)展class路徑的搜索是自動(dòng)的.總會(huì)搜索的.這樣,解決的方案就很簡單了,將所有要使用的第三方的jar包都復(fù)制到ext 目錄下.

三 User class擴(kuò)展方案

當(dāng)使用-jar執(zhí)行可執(zhí)行Jar包時(shí),JVM將Jar包所在目錄設(shè)置為codebase目錄,所有的class搜索都在這個(gè)目錄下開始.所以如果使用了其他第三方的jar包,一個(gè)比較可以接受的可配置方案,就是利用jar包的Manifest擴(kuò)展機(jī)制.
步驟如下:

 1.將需要的第三方的jar包,復(fù)制在同可執(zhí)行jar所在的目錄或某個(gè)子目錄下. 比如:jar 包在 /usrhome/yourJarExe.jar 那么你可以把所有jar包復(fù)制到/usrhome目錄下或/usrhome/lib 等類似的子目錄下.

 2.修改Manifest 文件

 在Manifest.mf文件里加入如下行

 Class-Path:classes12.jar lib/thirdlib.jar

 Class-Path 是可執(zhí)行jar包運(yùn)行依賴的關(guān)鍵詞.詳細(xì)內(nèi)容可以參考 http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html 。 要注意的是 Class-Path 只是作為你本地機(jī)器的CLASSPATH環(huán)境變量的一個(gè)縮寫,也就是說用這個(gè)前綴表示在你的jar包執(zhí)行機(jī)器上所有的CLASSPATH目錄下尋找相應(yīng)的 第三方類/類庫。你并不能通過 Class-Path 來加載位于你本身的jar包里面(或者網(wǎng)絡(luò)上)的jar文件。因?yàn)閺睦碚撋蟻碇v,你的jar發(fā)布包不應(yīng)該再去包含其他的第三方類庫(而應(yīng)該通過使用說明來 提醒用戶去獲取相應(yīng)的支持類庫)。如果由于特殊需要必須把其他的第三方類庫(jar, zip, class等)直接打包在你自己的jar包里面一起發(fā)布,你就必須通過實(shí)現(xiàn)自定義的ClassLoader來按照自己的意圖加載這些第三方類庫。


以上三種方法推薦第一種,擴(kuò)展性好,操作起來也最方便.
另外編寫自己的ClassLoader,來動(dòng)態(tài)載入class,是更加復(fù)雜和高級(jí)技術(shù).限于篇幅,不贅述.有興趣了解可以去google一下custom classloader,或者參考我的另一篇日志:讓classpath參數(shù)走開

Java的安全機(jī)制隨不同的JDK版本有不同的變化,會(huì)影響很多核心CLASS,比如Thread,所以很多大型商業(yè)軟件,要求JDK的版本很嚴(yán)格.部分原因也在此.這也要求在發(fā)布自己編寫的應(yīng)用時(shí)候,不管大小,都要說明開發(fā)和測試的JDK版本.


本文所述方法測試基于j2sdk 1.4.2_04-b05

----------------------------------------------------------------------------------------------

附:背景知識(shí)

自JDK 1.2以后,JVM采用了委托(delegate)模式來載入class.采用這種設(shè)計(jì)的原因可以參考http://java.sun.com/docs/books/tutorial/ext/basics/load.html

歸納來講:是基于JVM sandbox(沙盒)安裝模型上提供應(yīng)用層的可定制的安全機(jī)制.


Java虛擬機(jī)(JVM)尋找Class的順序

1. Bootstrap classes

屬于Java 平臺(tái)核心的class,比如java.lang.String等.及rt.jar等重要的核心級(jí)別的class.這是由JVM Bootstrap class loader來載入的.一般是放置在{java_home}"jre"lib目錄下

2. Extension classes

基于Java擴(kuò)展機(jī)制,用來擴(kuò)展Java核心功能模塊.比如Java串口通訊模塊comm.jar.一般放置在{Java_home}"jre"lib"ext目錄下

3. User classes

開發(fā)人員或其他第三方開發(fā)的Java程序包.通過命令行的-classpath或-cp,或者通過設(shè)置 CLASSPATH環(huán)境變量來引用.JVM通過放置在{java_home}"lib"tools.jar來尋找和調(diào)用用戶級(jí)的class.常用的 javac也是通過調(diào)用tools.jar來尋找用戶指定的路徑來編譯Java源程序.這樣就引出了User class路徑搜索的順序或優(yōu)先級(jí)別的問題.

 3.1 缺省值:調(diào)用Java或javawa的當(dāng)前路徑(.),是開發(fā)的class所存在的當(dāng)前目錄
 3.2 CLASSPATH環(huán)境變量設(shè)置的路徑.如果設(shè)置了CLASSPATH,則CLASSPATH的值會(huì)覆蓋缺省值
 3.3 執(zhí)行Java的命令行-classpath或-cp的值,如果制定了這兩個(gè)命令行參數(shù)之一,它的值會(huì)覆蓋環(huán)境變量CLASSPATH的值
 3.4 -jar 選項(xiàng):如果通過java -jar 來運(yùn)行一個(gè)可執(zhí)行的jar包,這當(dāng)前jar包會(huì)覆蓋上面所有的值.換句話說,-jar 后面所跟的jar包的優(yōu)先級(jí)別最高,如果指定了-jar選項(xiàng),所有環(huán)境變量和命令行制定的搜索路徑都將被忽略.JVM APPClassloader將只會(huì)以jar包為搜索范圍.
有關(guān)可執(zhí)行jar有許多相關(guān)的安全方面的描述,可以參考http://java.sun.com/docs/books/tutorial/jar/ 來全面了解.

這也是為什么應(yīng)用程序打包成可執(zhí)行的jar包后,不管你怎么設(shè)置classpath都不能引用到第三方j(luò)ar包的東西了

關(guān)于 什么是 jar文件可以參看以下鏈接:

http://www-128.ibm.com/developerworks/cn/java/j-jar/index.html


灑家測試的環(huán)境是:Ubuntu8.04+jdk 1.6+Eclipse 3.2。



SeesSea 2008-07-24 16:19 發(fā)表評(píng)論
]]>
JAVA實(shí)現(xiàn)CRC16校驗(yàn)http://www.aygfsteel.com/seesea/archive/2008/07/24/217149.htmlSeesSeaSeesSeaThu, 24 Jul 2008 04:11:00 GMThttp://www.aygfsteel.com/seesea/archive/2008/07/24/217149.htmlhttp://www.aygfsteel.com/seesea/comments/217149.htmlhttp://www.aygfsteel.com/seesea/archive/2008/07/24/217149.html#Feedback2http://www.aygfsteel.com/seesea/comments/commentRss/217149.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/217149.html要求:

CRC循環(huán)冗余錯(cuò)誤校驗(yàn)計(jì)算方法

CRC-16C(循環(huán)冗余錯(cuò)誤校驗(yàn))生成CRC-16校驗(yàn)字節(jié)的步聚如下:

(1)裝入一個(gè)16位寄存器,所有數(shù)位均為1

(2)16位寄存器的高位字節(jié)與開始8位字節(jié)進(jìn)行“異或”運(yùn)算。運(yùn)算結(jié)果放入這個(gè)16位寄存器。

(3)把這個(gè)16位寄存器向右移1位。

(4a)若向右(標(biāo)記位)移出的數(shù)位是1,則生成多項(xiàng)式1010000000000001和這個(gè)寄存器進(jìn)行“異或”運(yùn)算。

(4b)若向右移出的數(shù)位是0,則返回(3)

(5)重處處(3)(4),直至移出8位。

(6)另外8位與該16位寄存器進(jìn)行“異或”運(yùn)算。

(7)重處處(3)-(6),直至該報(bào)文所有字節(jié)均與16位寄存器進(jìn)行“異或”運(yùn)算,并移位8次。

(8)這個(gè)16位寄存器的內(nèi)容即2字節(jié)CRC錯(cuò)誤校驗(yàn)。

public class CRC {
    
private byte[] CRC=new byte[2];
    
    
byte data;
    
byte[] reg=new byte[2];
    
byte[] ploy=new byte[2];
    
byte Op;
    
    
public CRC(byte[] source){
        
//初始化多項(xiàng)式
        int temp=0xA001;
        ploy
=InttoByteArray(temp,2);
        
//初始化寄存器
        temp=0xFFFF;
        reg
=InttoByteArray(temp,2);
        
        
for(int i=0;i<source.length;i++){
            
//獲取數(shù)據(jù)
            data=source[i];
            
//與寄存器中數(shù)據(jù)進(jìn)行異或操作
            reg[1]=(byte) (reg[1]^data);
            
//移動(dòng)數(shù)據(jù)
            for(int j=0;j<8;j++){
                
//獲取數(shù)據(jù)的最后一位,即被移動(dòng)出的數(shù)據(jù)判斷是否與多項(xiàng)式異或
                Op=reg[0];
                
//右移一位
                reg=InttoByteArray(ByteArraytoInt(reg)>>1,2);
                
//如果移出數(shù)據(jù)為1
                if((Op&0x01)==1){
                    
//與多項(xiàng)式進(jìn)行異或操作
                    reg[0]=(byte) (reg[0]^ploy[0]);
                    reg[
1]=(byte) (reg[1]^ploy[1]);
                }                
            }
        }
        CRC
=reg;        
    }

    
public byte[] getCRC() {
        
return CRC;
    }
//格式化輔助函數(shù)
    private static byte[] InttoByteArray(int iSource, int iArrayLen) {
        
byte[] bLocalArr = new byte[iArrayLen];
        
for ( int i = 0; (i < 4&& (i < iArrayLen); i++) {
            bLocalArr[i] 
= (byte)( iSource>>8*& 0xFF );          
        }
        
return bLocalArr;
    }
    
    
private static int ByteArraytoInt(byte[] bRefArr) {
        
int iOutcome = 0;
        
byte bLoop;
        
        
for ( int i =0; i<bRefArr.length ; i++) {
            bLoop 
= bRefArr[i];
            iOutcome
+= (bLoop & 0xFF<< (8 * i);
          
        }         
        
return iOutcome;
    }    
}

開始把高低位搞混了,以為reg[0]是高位,調(diào)整了半天。郁悶!
另外,好像CRC算法也有好多種,我就沒在網(wǎng)上找到用戶要求的這種算法。貌似這個(gè)算法是Modbus協(xié)議中的CRC校驗(yàn)方式。有待確認(rèn)。



SeesSea 2008-07-24 12:11 發(fā)表評(píng)論
]]>
Ubuntu load/unload cycle count問題http://www.aygfsteel.com/seesea/archive/2008/07/22/216497.htmlSeesSeaSeesSeaMon, 21 Jul 2008 17:57:00 GMThttp://www.aygfsteel.com/seesea/archive/2008/07/22/216497.htmlhttp://www.aygfsteel.com/seesea/comments/216497.htmlhttp://www.aygfsteel.com/seesea/archive/2008/07/22/216497.html#Feedback0http://www.aygfsteel.com/seesea/comments/commentRss/216497.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/216497.html

安裝 laptop-mode,手動(dòng)編輯 /etc/laptop-mode/laptop-mode.conf,大概 216 行左右,按如下修改:

#
# Should laptop mode tools control the hard drive power management settings?
#
CONTROL_HD_POWERMGMT=1


#
# Power management for HD (hdparm -B values)
#
BATT_HD_POWERMGMT=192
LM_AC_HD_POWERMGMT=254
NOLM_AC_HD_POWERMGMT=254


第 一項(xiàng)是為了讓對(duì)硬盤參數(shù)的設(shè)置納入 laptop-mode 管理(默認(rèn)不開)。后面三個(gè)就是指定各種模式下的硬盤參數(shù)了。默認(rèn)情況下是 1/255/255。1 這個(gè)值太激進(jìn)(估計(jì) 3 分鐘 1 次就是它干的),我改成了 192(電池模式下畢竟還是要省電的,雖然這個(gè)值在不同品牌的硬盤可能表現(xiàn)差異很大,但是根據(jù)我搜索的結(jié)果,設(shè)置成 192 的時(shí)候硬盤已經(jīng)很難有機(jī)會(huì)自行 unload 了)。后兩個(gè)默認(rèn)值 255 是可以不改的,但是 255 是直接關(guān)閉 APM(高級(jí)電源管理),據(jù)說某些硬盤可能會(huì)忽略 255 這個(gè)極端值,所以改成 254(我的出發(fā)點(diǎn)其實(shí)還是不想舍棄 APM)。

然后是修改 /etc/default/acpi-support 這個(gè)文件。文件末尾兩個(gè)參數(shù),按如下設(shè)置:

# Switch to laptop-mode on battery power - off by default as it causes odd
# hangs on some machines
ENABLE_LAPTOP_MODE=true

# Spindown time on battery
SPINDOWN_TIME=60


第一項(xiàng)是開啟 laptop-mode,第二項(xiàng)似乎是控制用來控制硬盤空閑多長時(shí)間自動(dòng)斷電的,可根據(jù)自己喜好修改(默認(rèn)值是 12)。

經(jīng)幾天觀察,基本上這個(gè) Load Cycle Count 只在關(guān)機(jī)的時(shí)候才會(huì)增加了。

附:監(jiān)測 Load Cycle Count 的方法

sudo smartctl -a /dev/sda


設(shè)備可能是 /dev/hda(IDE 硬盤)或 /dev/sdb(第二塊硬盤)等等。如果覺得輸出太多,可以加上 grep 193。


sudo smartctl -a /dev/sda | grep 193

補(bǔ)充:
2008年07月24日
試運(yùn)行了幾天,至少從開機(jī)到關(guān)機(jī),Ubuntu中的這個(gè)值不再變化。不過好像是硬盤比以前熱一些了,或許是心里作用。但是在Vista中這個(gè)數(shù)據(jù)還在增加,具體值沒有算過,最近項(xiàng)目是Linux里的,不怎么用Win系統(tǒng),等常用時(shí)候在關(guān)注吧。


SeesSea 2008-07-22 01:57 發(fā)表評(píng)論
]]>
JAVA基本數(shù)據(jù)類型與其他語言數(shù)據(jù)類型之間的轉(zhuǎn)換方法 (ZT)http://www.aygfsteel.com/seesea/archive/2008/07/20/216159.htmlSeesSeaSeesSeaSun, 20 Jul 2008 04:02:00 GMThttp://www.aygfsteel.com/seesea/archive/2008/07/20/216159.htmlhttp://www.aygfsteel.com/seesea/comments/216159.htmlhttp://www.aygfsteel.com/seesea/archive/2008/07/20/216159.html#Feedback0http://www.aygfsteel.com/seesea/comments/commentRss/216159.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/216159.html通信格式轉(zhuǎn)換
Java和一些windows編程語言如c、c++、delphi所寫的網(wǎng)絡(luò)程序進(jìn)行通訊時(shí),需要進(jìn)行相應(yīng)的轉(zhuǎn)換
高、低字節(jié)之間的轉(zhuǎn)換
windows的字節(jié)序?yàn)榈妥止?jié)開頭
linux,unix的字節(jié)序?yàn)楦咦止?jié)開頭
java則無論平臺(tái)變化,都是高字節(jié)開頭  閱讀全文

SeesSea 2008-07-20 12:02 發(fā)表評(píng)論
]]>
XML讀取http://www.aygfsteel.com/seesea/archive/2008/07/19/216105.htmlSeesSeaSeesSeaSat, 19 Jul 2008 15:09:00 GMThttp://www.aygfsteel.com/seesea/archive/2008/07/19/216105.htmlhttp://www.aygfsteel.com/seesea/comments/216105.htmlhttp://www.aygfsteel.com/seesea/archive/2008/07/19/216105.html#Feedback0http://www.aygfsteel.com/seesea/comments/commentRss/216105.htmlhttp://www.aygfsteel.com/seesea/services/trackbacks/216105.html今天需要在C#下讀取XML,查了N多文章,都寫的太復(fù)雜。灑家只要讀取一些基本信息做系統(tǒng)初始化用。沒法子,只好翻出以前代碼。留在這里一份,以備后查。
另,前幾天找JAVA的讀取XML,網(wǎng)上很多也是比較繁復(fù)。費(fèi)了點(diǎn)力氣才搞定,回頭另開一篇粘進(jìn)去。

 XmlTextReader xmlReader = new XmlTextReader("path/filename.xml");
 while (xmlReader.Read())
 {
     if (xmlReader.Name == "XXX")
     {
         if (xmlReader.Read() && xmlReader.NodeType == XmlNodeType.Text)
         {
             xxx = xmlReader.Value;
          }

      }

 }

By SeeSea

SeesSea 2008-07-19 23:09 發(fā)表評(píng)論
]]>
主站蜘蛛池模板: 成武县| 榕江县| 小金县| 格尔木市| 元氏县| 邵阳市| 临湘市| 上林县| 通许县| 平阳县| 新巴尔虎左旗| 汨罗市| 泰兴市| 银川市| 崇州市| 崇义县| 武宁县| 汨罗市| 石楼县| 山阴县| 黄大仙区| 兴义市| 五华县| 临武县| 衡南县| 西城区| 贡嘎县| 柘荣县| 九龙城区| 丰顺县| 凤台县| 广汉市| 安西县| 泗洪县| 宁国市| 枝江市| 西和县| 石柱| 重庆市| 慈溪市| 北票市|