內容 |
|
我沒修改過maven settings.xml的內容
補充說明:
有關Oracle JDBC Driver部分必須自行由 Oracle.com網站下載,更名為ojdbc14-10.2.0.4.0.jar,然後放置到
C:\Users\Andowson\.m2\repository\com\oracle\ojdbc14\10.2.0.4.0目錄下
參考資料:
http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/
|
 |
|
您所提到的這兩項都算是正常:
模版檔中語法報錯,xml檔中的freemarker 標籤提示語法錯誤
我的開發環境如下:
Windows 7 + Java SE 6 Update 26 + Tomcat 7.0.14 + MySQL Community Server 5.5.13
Eclipse IDE for Java EE Developers Helios Sr2 + Maven 3.0.3 +
Eclipse Plugins: Subclipse, Eclipse ResourceBundle Editor, M2Eclipse, FindBugs
安裝路徑
C:\apache-maven-3.0.3
C:\apache-tomcat-7.0.14
C:\eclipse
C:\Program Files\Java\jdk1.6.0_26
C:\Program Files\MySQL\MySQL Server 5.5
1.安裝完成MySQL後,root帳號之密碼請設定為root,先建立一個資料庫名為jforum,同時建立一個使用者也是jforum,密碼可任意設定。
2.將jforum.war放到Tomcat 之webapps目錄下,啟動Tomcat後,開啟瀏覽器瀏覽http://localhost:8080/jforum/
3.依照畫面提示,選擇使用MySQL作為資料庫完成JForum安裝。
接下來,開啟Eclipse,設定Preferences->Installed JREs,刪除jre6,然後按下Add,選擇Standard VM,按下Next,在JRE Home: 後面的Directory...選擇C:\Program Files\Java\jdk1.6.0_26,按下Finish
點開Installed JREs下面的Execution Environments,點選J2SE-1.5,勾選jdk1.6.0_26
透過File > Import ...> SVN > 自SVN取回專案
將原始碼trunk由http://jforum2.googlecode.com/svn/trunk/取回
然後先Maven > Enable Dependency Management,再Update Dependencies
接著執行Run As > Maven package
這樣子就可以建立岀新的jforum.war了
|
 |
|
今天上午已將本站使用之JDK升級為JDK 6 Update 26,目前運作一切順利,如有發現任何異常請再回報,謝謝。
|
 |
|
很多公司的密碼政策都會要求定期更新一次密碼(例如90天),對於作業系統的帳號,需要使用者要登入時才能看到系統的提示訊息,告知其帳號還有幾天將要逾期。如果使用者都不登入作業系統,則該訊息將不會被使用者看到,很容易造成該使用者要用時才發現無法正常登入。
針對這個需求,我們可以透過一支發送通知信的shell script,每天定期掃一下系統的帳號檔/etc/passwd,搭配chage -l 指令找出即將(及已經)逾期的帳號有哪些,並個別發送信件給他們。底下參考的內容:
/root/admin/pwd_expire_notice.sh:
#!/bin/bash
# Name: pwd_expire_notice.sh
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 1.0
# Last Modified: 2011-06-22
noticefile=/tmp/pwd_expire.txt
ip=`/sbin/ifconfig eth0|grep "inet addr"|awk '{print $2}'|cut -d":" -f2`
echo $ip
D1=`date +%s`
for i in `cat /etc/passwd | grep bash | awk -F: '{print $1}'`
do
export LANG=en_US
echo -n "password for user ${i} will expire in "
exp_date=`chage -l $i|grep "Password [Ee]xpires"|awk -F: '{print $2}'`
D2=`date +%s -d"${exp_date}"`
((diff_sec=D2-D1))
daysleft=`echo - | awk -v SECS=$diff_sec '{printf "%d", SECS/(60*60*24)}'`
echo "$daysleft days"
if [ $daysleft -le 7 ]; then
echo "$i's password will expire in $daysleft days." > $noticefile
mailto=`grep $i /root/admin/mail.txt|awk -F: '{print $2}'`
if [ -n "$mailto" ]; then
echo "Send mail to ${mailto}"
export LANG=zh_TW.Big5
mail -s "密碼即將到期通知: $i@$ip 尚餘 $daysleft 日" $mailto < $noticefile
fi
fi
done
說明:
1.我們利用 chage -l username 可以找出全部的密碼相關日期資訊,利用grep指令過濾岀Password Expires(CentOS 4.x之前)或Password expires(CentOS 5.x)後面的日期字串,
2.接著再算出系統日期跟這個密碼到期日之間的天數差異
3.如果天數差異小於或等於7天,再比對mail.txt檔中有設定電子郵件的,我們就發送通知信給他
作業系統帳號和電子郵件信箱的對應檔(可針對想要收到通知信的帳號一一設定,格式為帳號:電子郵件,中間用一個冒號隔開不加空白)
/root/admin/mail.txt:
root:sys.admin@example.com
john:john.doe@example.com
設定排程自動執行
/etc/crontab:
# Notice password will expire (2011.06.22 by Andowson)
10 5 * * * root /root/admin/pwd_expire_notice.sh > /var/log/pwd_expire_notice.log 2>&1
注意:
您必須已經先設定好該部Linux主機可以發送電子郵件到您公司的信箱才行。例如安裝並設定Sendmail。
參考資料:
http://www.planetmy.com/blog/how-to-show-linux-user-password-expire/
http://www.unix.com/shell-programming-scripting/56451-days-difference-between-two-dates.html
|
 |
|
kevinwang72326您好:
您可以自己試試看,如果有遇到問題,再把您的做法發表上來,讓大家討論。
|
 |
|
有些資料庫使用Big5編碼,遇到Big5字集外的UTF-8中文字元時,可以採用將該字元轉換為&#xxxxx;格式,再跟原字串合併儲存,例如當字串變數str="中文喆堃"時,後面兩個中文字不在Big5字集的範圍內,我們希望將其轉為
"中文喆堃"這樣子的結果。
底下是範例程式
UTF8ToBig5.java:
package com.andowson.chinese;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
public class UTF8ToBig5 {
public static String convertHtml(String str) {
StringBuilder buf = new StringBuilder(str.length());
CharsetEncoder enc = Charset.forName("Big5").newEncoder();
for (int idx = 0; idx < str.length(); idx++) {
char ch = str.charAt(idx);
if (enc.canEncode(ch)) {
buf.append(ch);
} else {
buf.append("&#").append((int)ch).append(';');
}
}
return buf.toString();
}
/**
* @param args
*/
public static void main(String[] args) {
String str = "中文喆堃";
String result = convertHtml(str);
System.out.println(result);
}
}
參考資料:
http://stackoverflow.com/questions/1760766/how-to-convert-non-supported-character-to-html-entity-in-java
|
 |
|
caramel您好:
您可以參考這個連結上面的圖片及說明:
http://www.easywayserver.com/implementation-tomcat-clustering.htm
Vertical Clustering
|
 |
|
下載函式庫: HttpClient 4.1.1 (GA)
http://hc.apache.org/downloads.cgi
預先安裝函式庫:commons-logging-1.1.1.jar, httpcore-4.1.jar, httpclient-4.1.1.jar
這裡我以Servlet 3.0標準來當做練習,請在Tomcat 7.0以上版本執行:
HttpClientServlet.java:
package com.andowson.httpclient;
import java.io.IOException;
import java.io.PrintWriter;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
/**
* Servlet implementation class HttpClientServlet
*/
@WebServlet("/HttpClientServlet")
public class HttpClientServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public HttpClientServlet() {
super();
}
/**
* @see Servlet#getServletInfo()
*/
public String getServletInfo() {
return "HttpClient Servlet";
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String url = request.getParameter("url");
if (url == null) {
url = "https://ups.moe.edu.tw/";
}
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpHost proxy = new HttpHost("10.160.3.88", 8080);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
try {
TrustManager easyTrustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(
X509Certificate[] chain,
String authType) throws CertificateException {
// Oh, I am easy!
}
@Override
public void checkServerTrusted(
X509Certificate[] chain,
String authType) throws CertificateException {
// Oh, I am easy!
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, new TrustManager[] { easyTrustManager }, null);
SSLSocketFactory socketFactory = new SSLSocketFactory(sslcontext,
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
Scheme sch = new Scheme("https", 443, socketFactory);
httpclient.getConnectionManager().getSchemeRegistry().register(sch);
HttpGet httpget = new HttpGet(url);
System.out.println("executing request " + httpget.getRequestLine());
HttpResponse resp = httpclient.execute(httpget);
HttpEntity entity = resp.getEntity();
System.out.println("----------------------------------------");
System.out.println(resp.getStatusLine());
if (entity != null) {
System.out.println("Response content length: " + entity.getContentLength());
}
EntityUtils.consume(entity);
response.setContentType(entity.getContentType().toString());
PrintWriter out = response.getWriter();
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httpget, responseHandler);
System.out.println("----------------------------------------");
System.out.println(responseBody);
out.println(responseBody);
System.out.println("----------------------------------------");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} finally {
httpclient.getConnectionManager().shutdown();
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
修改web.xml,加入下列項目:
<servlet>
<servlet-name>HttpClientServlet</servlet-name>
<servlet-class>com.andowson.httpclient.HttpClientServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HttpClientServlet</servlet-name>
<url-pattern>/servlet/httpclient</url-pattern>
</servlet-mapping>
說明:
63-64行是如果伺服器需要透過Proxy才能連到Internet(例如公司內部網站)執行時需透過Proxy的設定方式,如果伺服器可以直接連接到Internet時這兩行需要mark為註解掉。
參考資料:
http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d4e537
|
 |
|
我猜測這個現象會發生的原因可能如下,
1.如果資料庫內碼是使用Big5編碼時,透過網頁上輸入的中文字(UTF-8)進入到應用伺服器時,被轉了一次碼(ISO-8859-1),再存到資料庫時,又轉了一次碼(Big5),例如下列的順序:
UTF-8->ISO-8859-1->Big5
當UTF-8轉成ISO-8859-1時,Unicode被轉成10進制的HTML Entity格式(如珉),然後跟其他可以轉成Big5的字元一起存到資料庫去。
2.等到從資料庫取回這個字串時,就會得到一個夾雜著HTML Entity格式的Big5字串,如果把這個字串直接傳給iText 去產生 pdf 檔,這些HTML Entity字串應該就會當做英文字母一樣輸出。於是就產生類似您所附上的sample.pdf 般的內容了。
好,了解原因後,要解決這個問題就很簡單了,只要在步驟2時補上將HTML Entity字串轉碼回原始編碼,再傳給iText去產生pdf即可。而要將HTML Entity字串轉碼回原始編碼只要呼叫
Apache Commons Lang的 StringEscapeUtils.unescapeHtml(java.lang.String) method即可。
在此以修改 iText in Action 2nd Edition所提供的 HelloWorld.java作為範例
HelloWorld.java:
/*
* This class is part of the book "iText in Action - 2nd Edition"
* written by Bruno Lowagie (ISBN: 9781935182610)
* For more info, go to: http://itextpdf.com/examples/
* This example only works with the AGPL version of iText.
*/
package com.andowson.pdf;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.commons.lang.StringEscapeUtils;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfWriter;
/**
* First iText example: Hello World.
*/
public class HelloWorld {
/** Path to the resulting PDF file. */
public static final String RESULT
= "D:/hello.pdf";
/**
* Creates a PDF file: hello.pdf
* @param args no arguments needed
*/
public static void main(String[] args)
throws DocumentException, IOException {
new HelloWorld().createPdf(RESULT);
}
/**
* Creates a PDF document.
* @param filename the path to the new PDF document
* @throws DocumentException
* @throws IOException
*/
public void createPdf(String filename)
throws DocumentException, IOException {
// step 1
Document document = new Document();
// step 2
PdfWriter.getInstance(document, new FileOutputStream(filename));
// step 3
document.open();
// Assumes that source string comes from database
String source = "測試物品-珉彣峯喆献";
// Unescapes the Unicode characters from HTML entities (decimal format) to string
String output = StringEscapeUtils.unescapeHtml(source);
// Specifies the file path to the Chinese font file
BaseFont bfChinese = BaseFont.createFont("C:/Windows/Fonts/kaiu.ttf",
BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
Font font = new Font(bfChinese, 12); // The font size is 12.
// step 4
document.add(new Paragraph(output, font));
// step 5
document.close();
}
}
下載函式庫:
http://itextpdf.com/
http://commons.apache.org/lang/
參考網址:
* Unicode 編碼字集
http://theorem.ca/~mvcorks/cgi-bin/unicode.pl.cgi?start=4E00&end=9FFF
* 解決iText輸出中文問題
http://blog.yam.com/rexmen/article/1888474
* Hello World example
http://itextpdf.com/examples/iia.php?id=12
|
 |
|
今天上午已將本站使用之JDK及Tomcat分別升級為JDK 6 Update 25及Tomcat 7.0.14,目前運作一切順利,如有發現任何異常請再回報,謝謝。
|
 |
|
中華電信100年研發及菁英人員徵才公告
中華電信將招募研發及菁英人員共 87 名,各職缺擔任工作、學歷資格條件及遴選相關事項,請參閱遴選簡章,一律採取網路報名方式辦理。
一、報名日期:100 年5 月13 日至100 年5 月30 日24:00
二、第一試(資歷論文審查)日期:100 月5 月31 日至100 年6 月3 日由本公司電信研究所及企業客戶分公司資歷審查小組上網遴選
三、第二試通知日期:100 年6 月8 日15:00 ( http://www.chttl.com.tw 網站公告外,詳細口試時程另行e-mail 通知)
四、第二試(口試)日期:100 年6 月11 日至100 年6 月12 日(若有異動,以通知變更日期為準)
五、放榜日期:100 年6 月15 日(若有異動,以通知變更日期為準)
詳請請看:
http://www.cht.com.tw/CompanyCat.php?CatID=4&NewsID=4312&Page=HotNewsDetail
|
 |
|
原本使用wget https://eip.mycomp.com 會出現錯誤訊息,將Apache所在主機(eip.mycomp.com)之/etc/httpd/conf/ssl.crt/ca.crt複製到wget所在主機後,改用下列方式連線即可:
wget --ca-certificate /path/to/ca.crt https://eip.mycomp.com
參考資料:
http://comments.gmane.org/gmane.comp.jakarta.repository/5996
|
 |
|
Hi newbiejforum,
My suggestion is that you can download jforum-2.2.1.war and install it.
Here is the download page:
http://code.google.com/p/jforum2/downloads/list
And see if JForum 2.2.1 works for you.
If it works, then you can start your customization on JForum 2.2.1's codebase.
|
 |
|
Hi newbiejforum,
Did you check out the JForum 2.2.1 code?
There is a line of import at the top of PostAction.java:
import org.apache.commons.lang.StringUtils;
And you'll need to add commons-lang-2.5.jar in your CLASSPATH to compile it.
Also you'll need to add servlet-api.jar to your CLASSPATH, too.
|
 |
|
|
 |
|