首页 > 程序开发 > 软件开发 > Java > 正文
SpringMVC,Mybatis,FreeMarker连接mycat示例(一)

项目结构如图:

首先是各种配置文件,属性文件

mycat.properties内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#数据库连接配置
#以下是mycat中间件连接
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:8066/SSMDB?useUnicode=true&characterEncoding=UTF-8
jdbc.username=wu
jdbc.password=hello123
 
#以下是mysql连接
#jdbc.url=jdbc:mysql://localhost:3306/MyCAT_DB?useUnicode=true&characterEncoding=UTF-8
#jdbc.username=root
#jdbc.password=123456
 
#定义初始连接数
jdbc.initialPoolSize=10
 
jdbc.maxPoolSize=200
jdbc.minPoolSize=5
jdbc.maxIdleTime=20
jdbc.acquireIncrement=10
jdbc.maxStatements=50
jdbc.idleConnectionTestPeriod=60
 
jdbc.initialSize=5
#定义最大空闲 
jdbc.maxIdle=20
#定义最小空闲
jdbc.minIdle=5
#定义最大连接数
jdbc.maxActive=200
jdbc.removeAbandonedTimeout=300
#定义最长等待时间 
jdbc.maxWait=60000
jdbc.maxOpenPreparedStatements=10

log4j.xml内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!--?xml version='1.0' encoding='UTF-8' ?-->
 
 
<log4j:configuration xmlns:log4j="https://jakarta.apache.org/log4j/">
 
     
        <layout class="org.apache.log4j.PatternLayout"><param name="ConversionPattern" value="%d [%7r] %6p - %30.30c - %m \n">
        </layout>
    </appender>
 
    <param name="Append" value="false"><param name="file" value="mycatDemo-debug.log">
        <layout class="org.apache.log4j.PatternLayout"><param name="ConversionPattern" value="%d [%7r] %6p - %30.30c - %m \n">
        </layout>
    </appender>
 
    <param name="DatePattern" value="'.'yyyy-MM-dd"><param name="Append" value="true"><param name="file" value="mycatDemo.log">
        <layout class="org.apache.log4j.PatternLayout"><param name="ConversionPattern" value="%d [%7r] %6p - %30.30c - %m \n">
        </layout>
        <filter class="org.apache.log4j.varia.LevelRangeFilter"><param name="LevelMin" value="DEBUG">
        </filter>
    </appender>
 
    <!--
            <param name="DatePattern" value="'.'yyyy-MM-dd"/>
            <param name="file" value="${las-im-scheduler.log.path}/las-report-zookeeper.log"/>
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="%d [%7r] %6p - %30.30c - %m \n"/>
            </layout>
        </appender>
 
        <category name="org.apache.zookeeper" additivity="false">
            <priority value="debug"/>
             
        </category>
    -->
 
    <category additivity="true" name="org.cometd">
        <priority value="ERROR">
         
    </appender-ref></priority></category>
 
    <category additivity="true" name="org.springframework.orm.ibatis3">
        <priority value="INFO">
         
    </appender-ref></priority></category>
 
    <category additivity="true" name="org.apache.ibatis">
        <priority value="ERROR">
         
    </appender-ref></priority></category>
 
    <category additivity="true" name="java.sql">
        <priority value="ERROR">
         
    </appender-ref></priority></category>
 
    <category additivity="true" name="com.mycat">
        <priority value="debug">
         
    </appender-ref></priority></category>
 
    <root>
        <priority value="ERROR">
         
         
    </appender-ref></appender-ref></priority></root>
 
</log4j:configuration>

sqlmap文件下的TestMapper.xml实体映射文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!--?xml version="1.0" encoding="UTF-8" ?-->
 
 
<mapper namespace="com.mycat.test.model.Test">
 
    <resultmap id="testResultMap" type="com.mycat.test.model.Test">
        <result column="id_" property="id">
        <result column="name_" property="name">
        <result column="user_id" property="userId">
    </result></result></result></resultmap>
 
    <select id="selectAll" resultmap="testResultMap">
        select * from sam_test
    </select>
 
    <select id="selectSome" parametertype="java.util.Map" resultmap="testResultMap">
        select * from sam_test limit #{offset},#{limit}
    </select>
 
    <select id="getObject" parametertype="java.lang.Object" resultmap="testResultMap">
        select * from sam_test where id_ = #{id}
    </select>
 
    <insert id="insert" keyproperty="id_" parametertype="com.mycat.test.model.Test">
        INSERT INTO sam_test(
        name_,
        user_id
        )
        VALUES(
            #{name,jdbcType=VARCHAR},
            #{userId,jdbcType=BIGINT}
        )
        <selectkey keyproperty="id" order="AFTER" resulttype="java.lang.Integer">
            select last_insert_id() as id
        </selectkey>
    </insert>
 
    <update id="update" parametertype="com.mycat.test.model.Test">
        update sam_test
        <set>
            <if test="name != null and name != ''">
              name_ = #{name},
            </if>
            <if test="userId != null">
              user_id = #{userId},
            </if>
        </set>
        where id_=#{id}
    </update>
 
    <!-- #{}中的参数名与方法中的参数的复杂数据类型的属性名一致 -->
    <delete id="delete" parametertype="java.lang.Integer">
        delete from sam_test where id_ = #{id}
    </delete>
 
    <select id="findOneByMap" resultmap="testResultMap">
        select * from sam_test where 1=1 AND
         
            ${param.name} = #{param.value}
         
        limit 0, 1
    </select>
 
    <select id="findOneByObject" parametertype="com.mycat.test.model.Test" resultmap="testResultMap">
        select * from sam_test
         
                 
                    and name_=#{name}
                 
                 
                    and user_id=#{userId}
                 
         
        limit 0, 1
    </select>
 
    <select id="findByMap" resultmap="testResultMap">
        select * from sam_test where 1=1 AND
         
            ${param.name} = #{param.value}
         
    </select>
 
    <select id="findByObject" parametertype="com.mycat.test.model.Test" resultmap="testResultMap">
        select * from sam_test
         
             
                and name_=#{name}
             
             
                and user_id=#{userId}
             
         
    </select>
 
    <select id="findByIn" resultmap="testResultMap">
        select * from sam_test where 1=1 AND
         
            ${param.name} IN (#{param.value})
         
    </select>
 
    <select id="findByLike" resultmap="testResultMap">
        select * from sam_test where 1=1 AND
         
            ${param.name} LIKE #{param.value}
         
    </select>
 
    <select id="getTotalCount" resulttype="int">
        select count(1) from sam_test
    </select>
 
    <select id="getCount" parametertype="java.util.Map" resulttype="int">
        select count(1) from sam_test where 1=1
         
        ${whereClause}
         
    </select>
 
    <select id="query" parametertype="java.util.Map" resultmap="testResultMap">
        select ${fieldsClause} from sam_test where 1=1
         
        ${whereClause}
         
         
        ${orderClause}
         
        limit ${limit} offset ${offset}
    </select>
</mapper>

spring-config-db.xml配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!--?xml version="1.0" encoding="UTF-8"?-->
       https://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       https://www.springframework.org/schema/tx
       https://www.springframework.org/schema/tx/spring-tx.xsd
       https://www.springframework.org/schema/aop
       https://www.springframework.org/schema/aop/spring-aop.xsd">
 
    <!-- 配置Mybatis会话工厂 -->
    <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactory">
 
        <!-- 注入DataSource -->
        <!-- 数据源 -->
        <property name="dataSource" ref="druidDataSource">
 
        <!-- 需要加载的mapper.xml,该bean被创建后,会自动加载这些文件。 -->
        <property name="mapperLocations">
            <list>
                  <!-- 自动匹配Mapper映射文件  --> 
                <value>classpath*:sqlmap/*Mapper.xml</value>
            </list>
        </property>
    </property></bean>
 
    <bean class="org.mybatis.spring.SqlSessionTemplate" id="sqlSession">
        <constructor-arg ref="sqlSessionFactory">
    </constructor-arg></bean>
 
    <!-- Druid集连接池,首先spring配置DataSource -->
    <bean class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close" id="druidDataSource" init-method="init">
        <property name="driverClassName" value="${jdbc.driverClassName}">
 
         <!-- 基本属性 url、user、password --> 
        <property name="url" value="${jdbc.url}">
        <property name="username" value="${jdbc.username}">
        <property name="password" value="${jdbc.password}">
        <!--initialSize: 初始化连接-->
        <property name="initialSize" value="${jdbc.initialSize}">
        <!--minIdle: 最小空闲连接-->
        <property name="minIdle" value="${jdbc.minIdle}">
        <!--maxActive: 最大连接数量-->
        <property name="maxActive" value="${jdbc.maxActive}">
         <!--removeAbandoned: 对泄漏的连接,是否自动回收超时连接-->
        <property name="removeAbandoned" value="true">
        <!--removeAbandonedTimeout: 超时时间(以秒数为单位)-->
        <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}">
        <!--maxWait: 超时等待时间以毫秒为单位 6000毫秒/1000等于60秒-->
        <property name="maxWait" value="${jdbc.maxWait}">
        <property name="defaultAutoCommit">
            <value>false</value>
        </property>
        <property name="validationQuery" value="select 1">
 
        <!-- 打开PSCache,并且指定每个连接上PSCache的大小 --> 
        <!-- 如果用Oracle,则把poolPreparedStatements配置为true,mysql可以配置为false。分库分表较多的数据库,建议配置为false --> 
        <property name="poolPreparedStatements" value="true">
        <property name="maxOpenPreparedStatements" value="${jdbc.maxOpenPreparedStatements}">
 
         <!-- 配置监控统计拦截的filters,去掉后监控界面sql无法统计 -->
         <!--<property name="filters" value="stat"/>-->
         <!-- 慢日志查询  缺省为3秒  修改为1010000 --> 
        <!-- <property name="connectionProperties" value="druid.stat.slowSqlMillis=5000" />   -->
 
    </property></property></property></property></property></property></property></property></property></property></property></property></property></bean>
 
    <!-- druid 监控  spring  --> 
    <!--  <bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"/> -->
 
    <!-- 按类型拦截配置 -->
    <!-- <bean id="druid-type-proxyCreator" class="com.alibaba.druid.support.spring.stat.BeanTypeAutoProxyCreator"> -->
    <!-- 所有ABCInterface的派生类被拦截监控  -->
    <!-- <property name="targetBeanType" value="xxxx.ABCInterface" />
         <property name="interceptorNames">
        <list>
            <value>druid-stat-interceptor</value>
        </list>
    </property>
    </bean> -->
 
 
    <!-- 按照BeanId来拦截配置 -->
    <!-- <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    <property name="proxyTargetClass" value="true" />
    <property name="beanNames">
        <list> -->
            <!-- 这里配置需要拦截的bean id列表 -->
            <!-- <value>xxx-dao</value>
            <value>xxx-service</value>
        </list>
    </property>
    <property name="interceptorNames">
        <list>
            <value>druid-stat-interceptor</value>
        </list>
    </property>
    </bean> -->
 
    <!-- 方法名正则匹配拦截配置 -->
    <!--    <bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">   -->
    <!--         <property name="patterns">   -->
    <!--             <list>   -->
    <!--                 <value>com.xinnet.*.service.*</value>   -->
    <!--                <value>com.mycompany.service.*</value> -->
    <!--                 <value>com.mycompany.dao.*</value> -->
    <!--             </list>   -->
    <!--         </property>   -->
    <!--     </bean>   -->
    <!--        -->
    <!--            -->
    <!--     </aop:config>   -->
 
 
     <!-- 配置事物管理器 -->
    <!-- 事务管理器 对mybatis操作数据库事务控制,spring使用jdbc的事务控制类 -->
    <bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager">
         <!-- 数据源 dataSource在上面配置了 -->
        <property name="dataSource" ref="druidDataSource">
    </property></bean>
    <!-- 配置声明式事务 -->
    <tx:annotation-driven transaction-manager="transactionManager">
 
</tx:annotation-driven></beans>

vcxml配置">spring-config-mvc.xml配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!--?xml version="1.0" encoding="UTF-8"?-->
<!--suppress ALL -->
            https://www.springframework.org/schema/beans
            https://www.springframework.org/schema/beans/spring-beans-3.1.xsd
            https://www.springframework.org/schema/context
            https://www.springframework.org/schema/context/spring-context-3.1.xsd
            https://www.springframework.org/schema/mvc
            https://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
            https://www.springframework.org/schema/util
            https://www.springframework.org/schema/util/spring-util-3.1.xsd">
 
     <!-- spring 自动扫描组件 -->
     <!-- 自动扫描 controller 包下的所有类 --> 
     <!-- mvc controller -->
    <context:component-scan base-package="com.mycat">
        <context:include-filter expression=".*.controller.*" type="regex">
        <context:include-filter expression=".*.service.*" type="regex">
        <context:include-filter expression=".*.dao.*" type="regex">
    </context:include-filter></context:include-filter></context:include-filter></context:component-scan>
 
     <!-- 开启注解的功能 -->
     <!-- 启动支持 mvc 的注解,比如  @Controller, @RequestMapping 等--> 
    <mvc:annotation-driven>
    <!--<bean id="conversionService"-->
    <!--class="org.springframework.format.support.FormattingConversionServiceFactoryBean">-->
    <!--<property name="formatterRegistrars">-->
    <!--<bean class="com.jd.common.springmvc.converter.DefaultFormatterRegistrar"/>-->
    <!--</property>-->
    <!--</bean>-->
 
    <!-- 解决静态资源被拦截的问题 -->
    <mvc:default-servlet-handler>
 
    <!-- static resources -->
    <!--<mvc:resources location="/static/" mapping="/static/**" cache-period="864000"/>-->
    <!--<mvc:resources location="/js/" mapping="/js/**" cache-period="864000"/>-->
 
 
     <!-- 配置视图解析器,使得在JSP中能够使用完整的JSTL功能 -->
    <!-- 设置视图解析工具 --> 
    <!-- template view -->
    <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer" id="freemarkerConfig">
        <property name="templateLoaderPath" value="/WEB-INF/views/">
        <property name="freemarkerSettings">
            <props>
                <prop key="template_update_delay">0</prop>
                <prop key="default_encoding">UTF-8</prop>
                <prop key="number_format">0.##########</prop>
                <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
                <prop key="classic_compatible">true</prop>
                <prop key="template_exception_handler">ignore</prop>
            </props>
        </property>
    </property></bean>
    <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver" id="freeMarkerViewResolver">
        <!--<property name="layoutUrl" value="layout/default.ftl"/>-->
        <property name="cache" value="false">
        <property name="suffix" value=".ftl">
        <property name="requestContextAttribute" value="request">
        <property name="exposeSpringMacroHelpers" value="true">
        <property name="exposeRequestAttributes" value="true">
        <property name="exposeSessionAttributes" value="true">
        <property name="contentType" value="text/html;charset=UTF-8">
    </property></property></property></property></property></property></property></bean>
 
    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="defaultContentType" value="text/html">
        <!-- not by accept header -->
        <property name="ignoreAcceptHeader" value="true">
        <!-- by extension -->
        <property name="mediaTypes"><map>
                <entry key="html" value="text/html">
                <entry key="xml" value="application/xml">
                <entry key="json" value="application/json">
            </entry></entry></entry></map>
        </property>
        <property name="viewResolvers">
            <list>
                <ref bean="freeMarkerViewResolver">
            </ref></list>
        </property>
        <property name="defaultViews">
            <list>
                <!-- for application/json -->
                <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
            </bean></list>
        </property>
    </property></property></bean>
 
    <!-- locale related -->
    <!--<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">-->
    <!--<property name="cookieName" value="_clientlocale"/>-->
    <!--<property name="defaultLocale" value="zh_CN"/>-->
    <!--<property name="cookieMaxAge" value="2147483647"/>-->
    <!--</bean>-->
    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="messageConverters">
            <util:list id="beanList">
                <ref bean="mappingJacksonHttpMessageConverter">
            </ref></util:list>
        </property>
    </bean>
    <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" id="mappingJacksonHttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/html;charset=UTF-8</value>
            </list>
        </property>
    </bean>
 
</bean></mvc:default-servlet-handler></mvc:annotation-driven></beans>

spring-config.xml配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!--?xml version="1.0" encoding="UTF-8"?-->
       https://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       https://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
 
 
    <!-- spring容器中最多只能定义一个context:property-placeholder spring中 context:property-placeholder
        导入多个独立的 .properties配置文件 Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer(或<context:property-placeholder/>),其余的会被Spring忽略掉
        通配符解决 -->
    <!-- 引入项目配置文件 -->
    <!-- 加载db.properties文件中的内容,db.properties文件中的key要有一定的特殊规则 -->
    <context:property-placeholder location="classpath*:mycat.properties">
 
    <import resource="spring-config-mvc.xml">
 
    <!--文件中主要负责配置:加载db.properties、配置数据源、配置SqlSessionFactoryBean、Mapper扫描器-->
    <import resource="spring-config-db.xml">
 
</import></import></context:property-placeholder></beans>

暂时先到这里

SpringMVC,Mybatis,FreeMarker连接mycat示例(一)的更多相关文章

  1. Spring MVC 环境搭建(maven+SpringMVC+mybatis+Freemarker)

    Spring MVC 环境搭建(maven+SpringMVC+mybatis+Freemarker) 一.准备工作 1.Eclipse Java EE IDE(4.4.1) 2.JDK 3.Tomc ...

  2. 学习笔记_J2EE_SSM_01_spring+springMVC+Mybatis整合_XML配置示例

    spring+springMVC+Mybatis整合_XML配置示例 1.概述 spring+springMVC+Mybatis整合  XML配置方式 1.1 测试环境说明 名称 版本 备注 操作系统 ...

  3. spring springmvc mybatis maven 项目整合示例-导航页面

    spring原理 实践解析-简单的helloworld spring原理案例-基本项目搭建 01 spring framework 下载 官网下载spring jar包 spring原理案例-基本项目 ...

  4. 解决springmvc+mybatis+mysql中文乱码问题【转】

    这篇文章主要介绍了解决java中springmvc+mybatis+mysql中文乱码问题的相关资料,需要的朋友可以参考下 近日使用ajax请求springmvc后台查询mysql数据库,页面显示中文 ...

  5. springmvc+mybatis+spring 整合源码项目

    A集成代码生成器 [正反双向(单表.主表.明细表.树形表,开发利器)+快速构建表单; freemaker模版技术 ,0个代码不用写,生成完整的一个模块,带页面.建表sql脚本,处理类,service等 ...

  6. 使用intellij idea搭建MAVEN+springmvc+mybatis框架

    原文:使用intellij idea搭建MAVEN+springmvc+mybatis框架 1.首先使用idea创建一个maven项目 2.接着配置pom.xml,以下为我的配置 <projec ...

  7. Spring+SpringMVC+Mybatis+MAVEN+Eclipse+项目完整环境搭建

    1.新建一个Maven项目,创建父项目. 2.创建子项目模块 3.创建javaWeb项目 4.创建后的项目目录结构 5.Maven文件配置 parent父项目pom.xml文件配置 <?xml ...

  8. IDEA下使用maven构建web项目(SpringMVC+Mybatis整合)

    需求背景:由于最近总是接到一些需求,需要配合前端团队快速建设移动端UI应用或web应用及后台业务逻辑支撑的需求,若每次都复用之前复杂业务应用的项目代码,总会携带很多暂时不会用到的功能或组件,这样的初始 ...

  9. Spring+SpringMVC+MyBatis+easyUI整合进阶篇(九)Linux下安装redis及redis的常用命令和操作

    redis简介 Redis是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. Redis与其他key-value缓存产品有以下三个特点: Redis支持数据的持久化,可以将内存 ...

随机推荐

  1. android YUV Sensor配置Camera应用的flash auto菜单

    请在Config.ftbl.flashlight.h (mediatek\custom\common\hal\flashlight\src)中. 将全部的两处凝视掉的code: //CameraPar ...

  2. SQLite: sqlite_master(转)

    转自:http://blog.sina.com.cn/s/blog_6afeac500100yn9k.html SQLite数据库中一个特殊的名叫 SQLITE_MASTER 上执行一个SELECT查 ...

  3. 学习思考:思考>努力

    学.习.思.考 学习.思考,这2个词,4个字,其实代表了4个不同的动作:学.习.思.考. 学,就是从外部(他人)获得. 习,就是练习,行动. 思,就是从内部(自己)获得. 考,就是考量,检测. 因此, ...

  4. js sort()函数 排序问题 var arr =['A-1-5-1','A-1-10-2','A-1-5-5','B-2-3-1','C-4-10-1'], 对这个数组进行排序,想达到的效果是["A-1-5-1", "A-1-5-5", "A-4-10-1", "A-1-10-2", "A-2-3-1"]

    先介绍个方法 charCodeAt() 方法可返回指定位置的字符的 Unicode 编码.这个返回值是 0 - 65535 之间的整数. stringObject.charCodeAt(index) ...

  5. STM32CUBEF4 实现USB 虚拟串口

    一.stm32cubemx 生成工程后USB转串口出现黄色感叹号的问题 如下图所示,在stm32cubemx工程中选择usb转串口功能Communication Device Class (Virtu ...

  6. android反编译odex文件

    关于android的反编译工具,相信大家并不陌生 如APK-TOOL,dex2jar APK-TOOL 用于反编译出布局文件 下载地址http://code.google.com/p/android- ...

  7. 9.Nexus私服安装配置

    第一步:下载nexus-webapp-1.9.2.4.war包,然后复制到tomcat下的webapps文件夹中 第二步:启动tomcat 第三步:訪问http://localhost:8080/ne ...

  8. 基于二叉树和双向链表实现限制长度的最优Huffman编码

    该代码採用二叉树结合双向链表实现了限制长度的最优Huffman编码,本文代码中的权重所有採用整数值表示.http://pan.baidu.com/s/1mgHn8lq 算法原理详见:A fast al ...

  9. 用SSL保Samba安全

    用SSL保Samba安全          在企业中用Samba做为文件服务器是非常容易的事了,那如何保证存储数据的安全,如何保证数据传输的安全呢?我以前介绍过通过Samba安全级别和加装防病毒软件在 ...

  10. android 移植ffmpeg后so库的使用

    今天折腾了一天,可算是有所收获,成功的用jni调用了libffmpeg中的一个方法-----avcodec_version(),至于avcodec_version()是干什么用的我不大清楚,应该是获取 ...