各位大哥,小弟才初学浅,经理让我自己搞一个项目,我搭建了一个SSH框架,本机上访问localhost不会延迟,但是通过网络IP访问会延迟,有时候会乱码,多刷新几次又不会了。。
     能教下我如何优化框架呢???
      1。如何配置连接池呢,我这个框架是用SPRING管理的,配置了连接池是否不能采用SPRING管理。
      2。如何用HIBERNATE缓存功能优化页面
希望大家能发点实际的代码,教我下这个SPRING配置文件怎么改???
    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value></property>
<property name="url"><value>jdbc:sqlserver://localhost:1433;DatabaseName=shilikaifa</value></property>
<property name="username"><value>sa</value></property>
<property name="password"><value>test</value></property>   
</bean>
<!--配置事务管理器--> 
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">    <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> 
<bean id="transactionProxyFactory" abstract="true" lazy-init="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">     <property name="transactionManager">          <ref local="transactionManager"/>     </property>     <property name="transactionAttributes">          <props>           <prop key="save*">PROPAGATION_REQUIRED</prop>            <prop key="insert*">PROPAGATION_REQUIRED</prop>            <prop key="del*">PROPAGATION_REQUIRED</prop>            <prop key="add*">PROPAGATION_REQUIRED</prop>            <prop key="update*">PROPAGATION_REQUIRED</prop>            <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>            <prop key="search*">PROPAGATION_REQUIRED,readOnly</prop>            <prop key="remove*">PROPAGATION_REQUIRED,readOnly</prop>            <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>            <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>            <prop key="count*">PROPAGATION_REQUIRED,readOnly</prop>            <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>     </props>    </property>     </bean> 
<bean id="hibernateInterceptor"
class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect  
</prop>
<!-- 表示允许自动提交 -->
<prop key="hibernate.connection.autocommit">true</prop>
<!-- 显示sql语句 -->
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/shili2/vo/Department.hbm.xml</value>
<value>com/shili2/vo/Role.hbm.xml</value>
<value>com/shili2/vo/Userd.hbm.xml</value>
<value>com/shili2/vo/UserRole.hbm.xml</value>
<value>com/shili2/vo/WghCustomer.hbm.xml</value>
<value>com/shili2/vo/WghCustomerBox.hbm.xml</value>
<value>com/shili2/vo/Guige1.hbm.xml</value>
<value>com/shili2/vo/Peima.hbm.xml</value>
<value>com/shili2/vo/Shangpin.hbm.xml</value>
<value>com/shili2/vo/Fjsx1.hbm.xml</value>
<value>com/shili2/vo/Jijie.hbm.xml</value>
<value>com/shili2/vo/Spgg1.hbm.xml</value>
<value>com/shili2/vo/Kehu.hbm.xml</value>
<value>com/shili2/vo/Spack.hbm.xml</value>
</list>
</property>
</bean>
<bean id="deptDao" class="com.shili2.dao.DeptDao"
abstract="true">
</bean>
<bean id="userDao" class="com.shili2.dao.UserDao"
abstract="true">
</bean>
<bean id="roleDao" class="com.shili2.dao.RoleDao"
abstract="true">
</bean>
<bean id="wghCustomerDao" class="com.shili2.dao.WghCustomerDao"
abstract="true">
</bean>
<bean id="tranSqlDao" class="com.shili2.dao.TranSqlDao"
abstract="true">
</bean>
<bean id="deptdaoimpl"
class="com.shili2.dao.impl.DeptDaoImpl" parent="deptDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="userdaoimpl"
class="com.shili2.dao.impl.UserDaoImpl" parent="userDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="roledaoimpl"
class="com.shili2.dao.impl.RoleDaoImpl" parent="roleDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="wghCustomerDaoimpl"
class="com.shili2.dao.impl.WghCustomerDaoImpl" parent="wghCustomerDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="tranSqlDaoimpl"
class="com.shili2.dao.impl.TranSqlDaoImpl" parent="tranSqlDao">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean name="/department" class="com.shili2.action.DeptAction">
<property name="deptDao">
<ref bean="deptdaoimpl" />
</property>
<property name="userDao">
<ref bean="userdaoimpl" />
</property>
</bean>
<bean name="/userd" class="com.shili2.action.UserAction">
<property name="userDao">
<ref bean="userdaoimpl" />
</property>
<property name="deptDao">
<ref bean="deptdaoimpl" />
</property>
</bean>
<bean name="/user" class="com.shili2.action.LoginAction">
<property name="userDao">
<ref bean="userdaoimpl" />
</property>
<property name="deptDao">
<ref bean="deptdaoimpl" />
</property>
<property name="wghCustomerDao">
<ref bean="wghCustomerDaoimpl"/>
</property>
</bean>
<bean name="/role" class="com.shili2.action.RoleAction">
<property name="roleDao">
<ref bean="roledaoimpl"/>
</property>
</bean>
<bean name="/wghCustomer" class="com.shili2.action.WghCustomerAction">
<property name="wghCustomerDao">
<ref bean="wghCustomerDaoimpl"/>
</property>
</bean>
<bean name="/commonQueryAction" class="com.shili2.action.CommonQueryAction">
<property name="wghCustomerDao">
<ref bean="wghCustomerDaoimpl"/>
</property>
</bean>
<bean name="/tranSqlAction" class="com.shili2.action.TranSqlAction">
<property name="tranSqlDao">
<ref bean="tranSqlDaoimpl"/>
</property>
</bean>
</beans>

解决方案 »

  1.   

    关于乱码的问题
    在web.xml文件里面加入如下过滤器: <filter>
            <filter-name>encodingFilter</filter-name>
            <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
            <init-param>
                <param-name>encoding</param-name>
                <param-value>GBK</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>
    </filter-mapping>