2013年8月23日

Exception handling in Spring MVC

Just very rough notes for exception handling in Spring MVC/Servlet

1. Servlet:
<error-page> ==> *.jsp/servlet (hard to use spring mvc classes)
or
<error-page> ==> spring mvc controller (fail if spring failed)

ps: in Servlet 3, can set default page for all exceptions/status codes

Ref:
http://blog.csdn.net/c5153000/article/details/6236815
http://kahimyang.info/kauswagan/howto_blogs/997-custom_error_pages_for_tomcat_jsf_applications
http://stackoverflow.com/questions/2748220/how-to-show-user-friendly-error-page-instead-of-tomcat-log-with-stack-trace-in-b
http://blog.newsplore.com/2010/08/04/restful-error-handling-with-tomcat-springmvc
http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-ann-customer-servlet-container-error-page
http://stackoverflow.com/questions/995248/how-to-get-the-message-in-a-custom-error-page-tomcat


2. Spring MVC:
Use @ExceptionHandler (must set for each controller)
or
@ContollerAdvice (3.2 only)
or
HandlerExceptionResover (need to set and implement yourself)

Ref:
http://stackoverflow.com/questions/3230358/spring-3-create-exceptionhandler-for-nosuchrequesthandlingmethodexception
http://fuliang.iteye.com/blog/947191
http://www.stormpath.com/blog/spring-mvc-rest-exception-handling-best-practices-part-2

3. hybrid
Use 2 for spring mvc and 1 for rest. Can share view(JSP)

2011年4月29日

Leaving only what is truly important ...

"For the past 33 years, I have looked in the mirror every morning and asked myself: "If today were the last day of my life, would I want to do what I am about to do today?" And whenever the answer has been "No" for too many days in a row, I know I need to change something...almost everything - all external expectations, all pride, all fear of embarrassment or failure - these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose." -- Steve Jobs

[1] http://news.stanford.edu/news/2005/june15/jobs-061505.html

2011年3月30日

About Blogger Now

距離上次開始玩 Blogger 到現在事情還真的改變了不少,以下是針對五年前 Blogger Beta 這篇文章作補充,簡單的回顧發生的事情:

原文:
花了一點時間轉換到 Blogger Beta,因為目前 Google 還沒提供簡便的轉換法,因此我就用手動的方式將舊站裡的文章和範本轉了過來,幸好資料不多。
現在已經沒有 Blogger Beta 了,改叫 Blogger in Draft XD,新的範本系統好用多了,雖然和舊的不相容了。

2011年2月12日

Simple Note for KVM

這篇主要是用來紀錄,如何使用KVM來執行實體硬碟上的Windows作業系統。方式很簡單,先安裝好KVM,並確定kernel module有正確啟動(注意,會和VirtualBox的module衝突),並擁有寫入/dev/kvm的權限。一般來說,Ubuntu應該會幫你處理好以上細節。接著確認好硬碟裝置檔名稱後,就可以輸入以下命令來啟動:
kvm -m 1024m -soundhw ac97 -hda /dev/sda &
要注意的是,KVM不能像VirtualBox一樣使用額外的MBR來開機,因此必須啟動原本硬碟上的MBR和開機管理程式,所以啟動時要特別注意不要讓KVM執行HOST作業系統。

因為新版的VirtualBox還算順暢,且使用上較為方便,因此目前我還是以它為主。

2011年1月26日

Enable LCD of Sony VAIO VPCS116FW on Ubuntu 10.10

Because SONY has modified BIOS for the Nvdia chip in VAIO, official Nvidia drivers can't drive built-in LCD correctly on Ubuntu 10.10. To make LCD usable, one need to:

2. Modify /etc/X11/xorg.conf to add the two lines to the "Device" section:
Option "ConnectedMonitor" "DFP-0"
Option "CustomEDID" "DFP-0: /proc/acpi/video/IGPU/LCD0/EDID"
With these two steps, LCD should work well. Additional external monitors can be added. Also, support of brightness control can be added. Following are my xorg.conf:


Reference:

Install Updated Nvidia Driver on Ubuntu

Since Ubuntu updates binary drivers infrqeuently, one can update them from the X Updates PPA. Just use these commands:
$ sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
$ sudo apt-get update
Then you can get stable release of X.org components, drivers from upstream. Please be aware that those packages are not supported by Ubuntu. Nextly, if you have installed the binary driver for an Nvidia card, you can just type:
$ sudo apt-get upgrade
to upgrade it. Otherwise you can use the "Additional Drivers" tool or just type:
$ sudo apt-get install nvidia-current
to install it. If CUDA/OpenCL headers are also needed, they can be installed by executing this command:
$ sudo apt-get install nvidia-current-dev
After installing all Nvidia packages, a GPGPU (OpenCL/CUDA) development environment is established successfully.

PS: You may need to manually delete some files/links from old version of drivers under the /usr/lib directory.

Reference:

2011年1月18日

Enable DirectVobSub with WMP on WIN7


To make DirectShow works, you can use win7dsfiltertweaker to disable formats support of the Media Foundation Framework (E.g.: MP4). This is a workaround, actually.