ssm-xml配置文件基本信息
2019-04-18 10:56
127 查看
本人小白,xml配置文件的头着实让我头疼,索性总结一下方便使用
Mybatis核心配置文件mybatis-config.xml
[code]<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> </configuration>
Mybatis映射文件mapper.xml
[code]<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace=""> </mapper>
springmvc-servlet.xml配置文件
(可以直接去spring手册上找)
[code]<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:component-scan base-package="org.example.web"/> <!-- ... --> </beans>
web.xml配置文件
[code]<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1" metadata-complete="true"> <!-- --> </web-app>
spring的核心配置文件applicationContext.xml
(直接去spring手册上找的)
[code]<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="..." class="..."> <!-- collaborators and configuration for this bean go here --> </bean> <bean id="..." class="..."> <!-- collaborators and configuration for this bean go here --> </bean> <!-- more bean definitions go here --> </beans>
Mybatis动态创建表
[code]<update id="addTable" parameterType="Map"> CREATE TABLE ${tableName}( id int(10) unsigned NOT NULL AUTO_INCREMENT, <foreach collection="tableColumns" item="value"> ${value} varchar(20) DEFAULT NULL, </foreach> PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=43 DEFAULT CHARSET=utf8; </update>
List<String> optionsDataForm;和List<String> describeDataForm;的读和写
[code]<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="physical.examination.record.dao.DataFormDao"> <select id="getDataForm" resultMap="dataform"> select * from tryAndTry </select> <resultMap type="entity.DataFormEntity" id="dataform"> <result column="Id" property="Id" jdbcType="INTEGER" /> <collection property="describeDataForm" ofType="java.lang.String"> <result column="describeDataForm" /> </collection> <collection property="optionsDataForm" ofType="java.lang.String"> <result column="optionsDataForm" /> </collection> </resultMap> <insert id="addDataFormStandard" parameterType="entity.DataFormEntity"> insert into tryAndTry(describeDataForm,optionsDataForm) values( <foreach collection="describeDataForm" item="describeDataForm">#{describeDataForm} </foreach> , <foreach collection="optionsDataForm" item="optionsDataForm">#{optionsDataForm} </foreach> ) </insert> </mapper>
(新手入门暂时遇到这些,后续再补充)
相关文章推荐
- 使用ssm框架在web.xml中的基本配置信息
- web.xml文件的作用及基本配置
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
- 使用Spring读取xml文件中的配置信息
- Java Web的web.xml文件作用及基本配置(转)
- SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
- SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
- 代码怎样引用plug-in.xml, menifest.mf等配置文件的信息
- web.xml文件的作用及基本配置
- jsp web.xml文件的作用及基本配置
- ssm框架下web项目,web.xml配置文件的作用(详解)
- C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)
- spring mvc学习笔记(一)web.xml文件配置的一点重要信息
- ssm(Spring+Spring mvc+mybatis)Spring配置文件——applicationContext-servlet.xml
- SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
- web.xml文件的作用及基本配置
- applicationContext.xml的基本配置文件
- 用java程序读取xml文件中的配置信息
- web.xml文件的作用及基本配置