pom.xml sample with spring, jetty

<project xmlns=”http://maven.apache.org/POM/4.0.0&#8243; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”&gt;
<modelVersion>4.0.0</modelVersion>
<groupId>springTestProject</groupId>
<artifactId>springTestProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
<spring.version>3.1.4.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.1</version>
</dependency>

<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.4</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
</dependency>

<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-sqlmap</artifactId>
<version>2.3.4.726</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>7.6.12.v20130726</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>7.6.12.v20130726</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.0.1.Final</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>

<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>5.4.0</version>
</dependency>

<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.6</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3</version>
</dependency>

<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>

<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.1.0</version>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>

<dependency>
<groupId>org.perf4j</groupId>
<artifactId>perf4j</artifactId>
<version>0.9.16</version>
</dependency>
<!– AOP dependency –>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>

<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.3</version>
</dependency>

<!– db related –>
<!– <dependency>
<groupId>ms.heritage</groupId>
<artifactId>ms-heritage-ojdbc6</artifactId>
<version>0.0.1</version>
</dependency> –>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<!– ibatis –>
<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-sqlmap</artifactId>
<version>2.3.4.726</version>
</dependency>

<!– json –>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib-ext-spring</artifactId>
<version>1.0.2</version>
</dependency>

<!– javamelody –>
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-core</artifactId>
<version>1.47.0</version>
</dependency>

<!– Spring Security –>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.version}</version>

</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.version}</version>

</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<outputDirectory>release</outputDirectory>
<warName>springTestProject</warName>
</configuration>
</plugin>

</plugins>
</build>
</project>

redis with keepalived

keepalive issue:

http://www.cyberciti.biz/faq/linux-unix-verify-keepalived-working-or-not/

/sbin/ip addr del 10.194.0.200/32 dev eth1

tcpdump -vv -n -i eth3 host 10.194.3.200

# uuptable related

cat /var/logs/mess

/sbin/iptables -I INPUT -i eth1 -d 224.0.0.0/8 -j ACCEPT

/sbin/iptables -A INPUT -p 112 -i eth1 -j ACCEPT

/sbin/iptables -A OUTPUT -p 112 -o eth1 -j ACCEPT

/sbin/service iptables save

———————–

redis conf in java

<bean id=”jedisNewsPoolConfig”>

<property name=”maxActive” value=”20000″ />

<property name=”maxIdle” value=”500″ />

<property name=”maxWait” value=”500″ />

<property name=”testOnBorrow” value=”true” />

</bean>

<bean id=”jedisNewsConnectionFactory”

class=”org.springframework.data.redis.connection.jedis.JedisConnectionFactory”>

<property name=”hostName” value=”${redis.host}” />

<property name=”port” value=”${redis.port}” />

<property name=”password” value=”${redis.pass}” />

<property name=”poolConfig” ref=”jedisNewsPoolConfig” />

</bean>

<bean id=”redisNewsTemplate”>

<property name=”connectionFactory” ref=”jedisNewsConnectionFactory” />

</bean>

keepalived shell script :

!!!Master and Slave 分别安装 keepalived,需要OpenSSL lib

{{{

tar zxf keepalived-1.2.8.tar.gz

cd keepalived-1.2.8

./configure  –prefix=/usr/local/keepalived/ && make && make install

}}}

10.194.0.199

!1.编写Keepalived conf

!!!Master  (192.168.186.128)

*vi /etc/keepalived/keepalived.conf

{{{

vrrp_script chk_redis {

script “/etc/keepalived/scripts/redis_check.sh”   ###监控脚本

interval 2                                        ###监控时间

}

vrrp_instance VI_1 {

state MASTER                            ###设置为MASTER

interface eth0                          ###监控网卡

virtual_router_id 51

priority 101                            ###权重值,比Slave稍高

authentication {

auth_type PASS             ###加密

auth_pass redis            ###密码

}

track_script {

chk_redis                       ###执行上面定义的chk_redis

}

virtual_ipaddress {

10.194.3.200                         ###VIP

}

notify_master /etc/keepalived/scripts/redis_master.sh

notify_backup /etc/keepalived/scripts/redis_backup.sh

notify_fault  /etc/keepalived/scripts/redis_fault.sh

notify_stop   /etc/keepalived/scripts/redis_stop.sh

}

}}}

!!!Slave  (192.168.186.129)

*vi /etc/keepalived/keepalived.conf

{{{

vrrp_script chk_redis {

script “/etc/keepalived/scripts/redis_check.sh”   ###监控脚本

interval 2                                        ###监控时间

}

vrrp_instance VI_1 {

state BACKUP                                ###设置为BACKUP

interface eth0                              ###监控网卡

virtual_router_id 51

priority 100                                ###比MASTRE权重值低

authentication {

auth_type PASS

auth_pass redis                ###密码与MASTRE相同

}

track_script {

chk_redis                       ###执行上面定义的chk_redis

}

virtual_ipaddress {

10.194.3.200                         ###VIP

}

notify_master /etc/keepalived/scripts/redis_master.sh

notify_backup /etc/keepalived/scripts/redis_backup.sh

notify_fault  /etc/keepalived/scripts/redis_fault.sh

notify_stop   /etc/keepalived/scripts/redis_stop.sh

}

}}}

!2.编写Event Script:

!!!Master and Slave 各自建立 Redis check, fault , stop script

*vi /etc/keepalived/scripts/redis_check.sh

{{{

#!/bin/bash

ALIVE=`/usr/local/redis-stable/src/redis-cli PING`

if [ “$ALIVE” == “PONG” ]; then

echo $ALIVE

exit 0

else

echo $ALIVE

exit 1

fi

}}}

*vi /etc/keepalived/scripts/redis_fault.sh

{{{

#!/bin/bash

LOGFILE=/var/log/keepalived-redis-state.log

echo “[fault]” >> $LOGFILE

date >> $LOGFILE

}}}

*vi /etc/keepalived/scripts/redis_stop.sh

{{{

#!/bin/bash

LOGFILE=/var/log/keepalived-redis-state.log

echo “[stop]” >> $LOGFILE

date >> $LOGFILE

}}}

—-

!!!Master:

*vi /etc/keepalived/scripts/redis_master.sh

{{{

#!/bin/bash

REDISCLI=”/usr/local/redis-stable/src/redis-cli”

LOGFILE=”/var/log/keepalived-redis-state.log”

echo “[master]” >> $LOGFILE

date >> $LOGFILE

echo “Being master….” >> $LOGFILE 2>&1

echo “Run: SLAVEOF 10.194.3.194 6379” >> $LOGFILE

$REDISCLI SLAVEOF 10.194.3.194 6379 >> $LOGFILE  2>&1

echo “Run: sleep 10 (for waiting sync data)” >> $LOGFILE

sleep 10 #延迟10秒以后待数据同步完成后再取消同步状态

echo “Run: SLAVEOF NO ONE” >> $LOGFILE

$REDISCLI SLAVEOF NO ONE >> $LOGFILE 2>&1

}}}

—-

*vi /etc/keepalived/scripts/redis_backup.sh

{{{

!/bin/bash

REDISCLI=”/usr/local/redis-stable/src/redis-cli”

LOGFILE=”/var/log/keepalived-redis-state.log”

echo “[backup]” >> $LOGFILE

date >> $LOGFILE

echo “Being slave….” >> $LOGFILE 2>&1

echo “Run: sleep 10 (wait for sync data by others)” $LOGFILE

sleep 15 #延迟15秒待数据被对方同步完成之后再切换主从角色

echo “Run: SLAVEOF 10.194.3.194 6379″ >> $LOGFILE

$REDISCLI SLAVEOF 10.194.3.194 6379 >> $LOGFILE  2>&1

}}}

—-

!!!Slave:

*vi /etc/keepalived/scripts/redis_master.sh

{{{

#!/bin/bash

REDISCLI=”/usr/local/redis-stable/src/redis-cli”

LOGFILE=”/var/log/keepalived-redis-state.log”

echo “[master]” >> $LOGFILE

date >> $LOGFILE

echo “Being master….” >> $LOGFILE 2>&1

echo “Run: SLAVEOF NO ONE” >> $LOGFILE

$REDISCLI SLAVEOF NO ONE >> $LOGFILE 2>&1

}}}

—-

*vi /etc/keepalived/scripts/redis_backup.sh

{{{

#!/bin/bash

REDISCLI=”/usr/local/redis-stable/src/redis-cli”

LOGFILE=”/var/log/keepalived-redis-state.log”

echo “[backup]” >> $LOGFILE

date >> $LOGFILE

echo “Being slave….” >> $LOGFILE 2>&1

echo “Run: sleep 10 (for waiting sync data for others)” >> $LOGFILE

sleep 15 #延迟15秒待数据被对方同步完成之后再切换主从角色

echo “Run: SLAVEOF 10.194.3.194 6379” >> $LOGFILE

$REDISCLI SLAVEOF 10.194.3.194 6379 >> $LOGFILE  2>&1

}}}

!3.给脚本都加上可执行权限:

chmod +x /etc/keepalived/scripts/*.sh

!4.启动并测试

{{{

启动各自Redis Server:

/usr/local/redis-stable/src/redis-server

启动各自 Keepalived

/usr/local/keepalived/sbin/keepalived  -D -f /etc/keepalived/keepalived.conf

完成部署。

}}}

#################################################################################

redis shell script:

{{{

cd /etc/rc.d/init.d/

vi redis

}}}

{{{

#!/bin/bash

#chkconfig: 2345 55 25

#description: Starts,stops and restart the redis-server

#Ver:1.1

#Write by ND chengh(200808)

#usage: ./script_name -p [port] {start|stop|status|restart}

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check networking is up.

[ “$NETWORKING” = “no” ] && exit 0

RETVAL=0

REDIS_PORT=6379

PID=

if [ “$1” = “-p” ]; then

    REDIS_PORT=$2

    shift 2

fi

REDIS_DIR=”/usr/local/redis-stable”

REDIS=”${REDIS_DIR}/src/redis-server”

PROG=$(basename $REDIS)

CONF=”${REDIS_DIR}/etc/redis-${REDIS_PORT}.conf”

if [ ! -f $CONF ]; then

   if [ -f “${REDIS_DIR}/redis.conf” ];then

      CONF=”${REDIS_DIR}/redis.conf”

   else

      echo -n $”$CONF not exist.”;warning;echo

      exit 1

   fi

fi

PID_FILE=`grep “pidfile” ${CONF}|cut -d ‘ ‘ -f2`

PID_FILE=${PID_FILE:=/var/run/redis/redis.pid}

LOCKFILE=”/var/lock/subsys/redis/redis-${REDIS_PORT}”

if [ ! -x $REDIS ]; then

    echo -n $”$REDIS not exist.”;warning;echo

    exit 0

fi

start() {

    echo -n $”Starting $PROG: ”

    $REDIS $CONF

    RETVAL=$?

    if [ $RETVAL -eq 0 ]; then

        success;echo;touch $LOCKFILE

    else

        failure;echo

    fi

    return $RETVAL

}

stop() {

    echo -n $”Stopping $PROG: ”

    if [ -f $PID_FILE ] ;then

       read PID <  “$PID_FILE”

    else

       failure;echo;

       echo -n $”$PID_FILE not found.”;failure;echo

       return 1;

    fi

    if checkpid $PID; then

     kill -TERM $PID >/dev/null 2>&1

        RETVAL=$?

        if [ $RETVAL -eq 0 ] ;then

                success;echo

                echo -n “Waiting for Redis to shutdown ..”

         while checkpid $PID;do

                 echo -n “.”

                 sleep 1;

                done

                success;echo;rm -f $LOCKFILE

        else

                failure;echo

        fi

    else

        echo -n $”Redis is dead and $PID_FILE exists.”;failure;echo

        RETVAL=7

    fi

    return $RETVAL

}

restart() {

    stop

    start

}

rhstatus() {

    status -p ${PID_FILE} $PROG

}

hid_status() {

    rhstatus >/dev/null 2>&1

}

case “$1” in

    start)

        hid_status && exit 0

        start

        ;;

    stop)

        rhstatus || exit 0

        stop

        ;;

    restart)

        restart

        ;;

    status)

        rhstatus

        RETVAL=$?

        ;;

    *)

        echo $”Usage: $0 -p [port] {start|stop|status|restart}”

        RETVAL=1

esac

exit $RETVAL

}}}

{{{

chmod +x redis

sudo /sbin/chkconfig

sudo ln -s /sbin/chkconfig /usr/bin/

chkconfig –add redis

chkconfig –level 345 redis on

}}}

spring startup

src/main/webapp/WEB-INF/web.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns=”http://java.sun.com/xml/ns/javaee&#8221; xmlns:web=”http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&#8221; xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&#8221; id=”WebApp_ID” version=”2.5″>
<display-name>springTestProject</display-name>

<!– ====================== Integrate Spring Framework 3.1 ===================== –>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
<!– /WEB-INF/spring-security.xml –>
</param-value>
</context-param>

<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>

<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>180000</param-value>
</context-param>

<!– ========================= Listener Definitions ============================ –>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<!– ==================== Internationalization Filter ========================== –>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!– Spring Security
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>–>

<!– ======================== Spring MVC Dispatcher ================================== –>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/dispatcher-servlet.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>

<!– ======================== Application Common Definitions ========================= –>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

================================================================

src/main/webapp/WEB-INF/dispatcher-servlet.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”http://www.springframework.org/schema/beans&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
xmlns:p=”http://www.springframework.org/schema/p&#8221; xmlns:context=”http://www.springframework.org/schema/context&#8221;
xmlns:mvc=”http://www.springframework.org/schema/mvc&#8221; xmlns:aop=”http://www.springframework.org/schema/aop&#8221;
xmlns:util=”http://www.springframework.org/schema/util&#8221;
xsi:schemaLocation=”http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd&#8221;
default-autowire=”byName”>

<aop:aspectj-autoproxy proxy-target-class=”true” />

<!– ======================= Using Annotation Handler Mapping =========================== –>
<bean class=”org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping”/>

<!– ================== Spring View Resolver Definition ================================= –>
<bean class=”org.springframework.web.servlet.view.InternalResourceViewResolver”>
<property name=”viewClass” value=”org.springframework.web.servlet.view.JstlView” />
<property name=”prefix” value=”/WEB-INF/jsp/” />
<property name=”suffix” value=”.jsp” />
</bean>

<!– =========================== Auto IOC cache component scan ========================== –>
<context:component-scan base-package=”stp.controller”>
<context:include-filter type=”regex” expression=”.*Controller.*” />
</context:component-scan>

<bean class=”org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter”>
<property name=”messageConverters”>
<list>
<ref bean=”mappingJacksonHttpMessageConverter” />
</list>
</property>
</bean>
<bean id=”mappingJacksonHttpMessageConverter” class=”org.springframework.http.converter.json.MappingJacksonHttpMessageConverter” />

</beans>

 

================================================================

src/main/webapp/WEB_INF/applicationContext.xml

 

<?xml version=”1.0″ encoding=”UTF-8″?>

<beans xmlns=”http://www.springframework.org/schema/beans&#8221;
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns:jee=”http://www.springframework.org/schema/jee&#8221;
xmlns:p=”http://www.springframework.org/schema/p&#8221; xmlns:tx=”http://www.springframework.org/schema/tx&#8221;
xmlns:context=”http://www.springframework.org/schema/context&#8221;
xmlns:aop=”http://www.springframework.org/schema/aop&#8221;
xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd&#8221;
default-autowire=”byName”>

<!– ========================== Jackson Object Mapper ========================= –>
<bean id=”jacksonObjectMapper” class=”org.codehaus.jackson.map.ObjectMapper”></bean>
</beans>

================================================================

start :

http://www.tutorialspoint.com/spring/spring_web_mvc_framework.htm

@request

http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/mvc.html

localization

http://www.mkyong.com/spring-mvc/spring-mvc-internationalization-example/

useful js plugin

detect caps lock:

 

fixed menu on scroll:

 

sha-1 in js:

 

scroll js:

 

override alert js

window.alert = function(message, cb) {
$(document.createElement(‘div’)).attr({
title : ‘提示’,
‘class’ : ‘dialog’
}).html(message).dialog({
buttons : {
OK : function() {
$(this).dialog(‘close’);
}
},
close : function() {
if (cb != undefined) {
cb();
}
$(this).remove();
},
draggable : true,
modal : true,
resizable : false,
width : 300,
height: “auto”,
minHeight: 10
})
};
window.confirm = function(message, cb) {
$(document.createElement(‘div’)).attr({
title : ‘提示’,
‘class’ : ‘dialog’
}).html(message).dialog({
buttons : {
OK : function() {
cb(true);
$(this).remove();
},
Cancel : function() {
$(this).dialog(‘close’);
}
},
close : function() {
cb(false);
$(this).remove();
},
draggable : true,
modal : true,
resizable : false,
width : 300,
height: “auto”,
minHeight: 10
})
};