2009年3月18日

          Struts2學(xué)習(xí)

          幾年前學(xué)習(xí)了一陣子Struts2,也開發(fā)了些小項(xiàng)目,后來工作變動,幾年沒動技術(shù),這兩天又想撿起來,發(fā)現(xiàn)一些配置有了變化,重新學(xué)習(xí),記錄些內(nèi)容,供自己查詢。

          環(huán)境沒敢用最新的,MyEclipse用的是8.5的版本,Tomcat最終選擇了6,JDK也是用的7,Struts2的版本2.3.16.3。通常的配置沒什么要記錄的,主要記錄下出問題的地方:
          1、Tomcat
          從MyEclipse啟動Tomcat一直報(bào)錯(cuò),后來下載了一個(gè)tcnative-1.dll文件才解決,版本要求比較嚴(yán)格,對于Tomcat6.0.41而言,這個(gè)動態(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

          posted @ 2014-07-16 10:47 SeesSea 閱讀(198) | 評論 (0)編輯 收藏

          在ubuntu 8.04下安裝Oracle 11g方法

          項(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)不要急著解壓,一會我會告訴你解壓在哪的。

          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)換為超級用戶:(注意,這里用sudo su -而不是sudo -s是有原因的:sudo su - 將用戶轉(zhuǎn)換為超級用戶,并新起一個(gè)會話(空的會話),而不是像sudo -s那樣將當(dāng)前會話傳遞個(gè)新的超級用戶,減少環(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í)候會出現(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
          增加用戶和組,并修改一些配置。這一步很重要!如果不是很有把握,不要隨便改。(為了便于解釋,增加了行號):
          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的安裝程序不會出問題。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)值。這些修改將會增加系統(tǒng)文件描述符的數(shù)量、增加共享內(nèi)存大小和修改一些網(wǎng)絡(luò)子系統(tǒng)參數(shù)。這些修改是否會對你的系統(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)制使用剛才我們增加的東西,我們再增加下面這些到/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用戶登陸,(不然會出安裝界面出不來)
          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í)會報(bào)錯(cuò),因?yàn)閡butunbu 不支持RPM包)。[/color]

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

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


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

          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ù)庫的啟動腳本,名字可以叫做: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ī)自動啟動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 啟動數(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 啟動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)對安裝和運(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.



           

          posted @ 2009-03-18 10:52 SeesSea 閱讀(540) | 評論 (0)編輯 收藏

          <2009年3月>
          22232425262728
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 安顺市| 文昌市| 朔州市| 朝阳县| 开封县| 沈丘县| 营口市| 静安区| 桦川县| 康平县| 二手房| 师宗县| 汤原县| 云南省| 盘锦市| 光山县| 休宁县| 修文县| 黎城县| 宁都县| 开平市| 伊吾县| 宣化县| 沛县| 泉州市| 荔浦县| 普兰县| 黔南| 霍城县| 壶关县| 延长县| 西城区| 安西县| 东乡族自治县| 宝山区| 苗栗市| 安宁市| 新余市| 滦南县| 当雄县| 阜南县|