zoukankan      html  css  js  c++  java
  • 【JavaWeb】SpringMvc+Hibernate+MySql问题集合

    1. Spring @ResponseBody返回中文乱码:

    配置文件中增加:

        <mvc:annotation-driven>
            <mvc:message-converters register-defaults="true">
                <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                    <constructor-arg value="UTF-8" />
                    <property name="writeAcceptCharset" value="false" />
                </bean>
            </mvc:message-converters>
        </mvc:annotation-driven>

    2. Spring 事物自动提交和自动关闭连接

    配置文件中加入:

    //自动提交事物
    <property name="hibernate.connection.autocommit">true</property>
    //事物提交之后关闭数据库的连接 
    <property name="hibernate.connection.release_mode">after_transaction</property>

    3. hql limit 无效

    //设置最大结果数
    setMaxResults(int max)
    //设置查询偏移量
    setFirstResults(int first)

    4.mysql修改超时时间

    同时设置wait_timeout(服务器关闭非交互式连接前的等待时间)和interactive_timeout服务器关闭交互式连接前的等待时间)方可生效

    
    show global variables like  'wait_timeout'
    
    set global wait_timeout=300;
    
    show global variables like  'interactive_timeout';
    
    set global interactive_timeout=300;

    5. mysql update整表无效

    //错误代码
    You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

    将默认的SQL_SAFE_UPDATES=1改为 SQL_SAFE_UPDATES=0;

     set SQL_SAFE_UPDATES=0;
  • 相关阅读:
    ExtJs中动态加载机制研究(转)
    ExtJs4 学习3 combox自动加载的例子
    Extjs 4学习2
    ExtJS 4学习
    javascript学习(知识点整理)
    ExtJS智能提示工具spket安装与破解
    eclipse慢 优化(转)
    疯狂学习java web5(SSI框架)
    疯狂学习java web4(jsp)
    疯狂学习java web3(javaScript)
  • 原文地址:https://www.cnblogs.com/cnsec/p/13286770.html
Copyright © 2011-2022 走看看