`
747017186
  • 浏览: 331506 次
社区版块
存档分类
最新评论

SSM的搭建

 
阅读更多

前一段时间自己搭建了ssm框架(maven+spring+spring mvc+mybatis)。下面直接看代码。看看maven所需要的jar。

pom.xml

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
	<groupId>hw.hlatform.secg</groupId>
	<artifactId>secg-parent</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<relativePath>../secg-parent/pom.xml</relativePath>
  </parent>
  
  <artifactId>IHos-Api</artifactId>
  <packaging>war</packaging>
  <name>IHos-Api Maven Webapp</name>
  <url>http://maven.apache.org</url>
  
  <properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
		<groupId>javax.servlet</groupId>
		<artifactId>javax.servlet-api</artifactId>
	</dependency>
	<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
	<dependency>
	    <groupId>commons-logging</groupId>
	    <artifactId>commons-logging</artifactId>
	</dependency>
	<dependency>
	    <groupId>org.glassfish.gmbal</groupId>
	    <artifactId>gmbal-api-only</artifactId>
	    <version>3.2.0-b003</version>
	</dependency>
	<dependency>
	    <groupId>org.glassfish.ha</groupId>
	    <artifactId>ha-api</artifactId>
	    <version>3.1.9</version>
	</dependency>
	<dependency>
	    <groupId>javax.xml.bind</groupId>
	    <artifactId>jaxb-api</artifactId>
	    <version>2.2.12</version>
	</dependency>
	<dependency>
	    <groupId>com.sun.xml.bind</groupId>
	    <artifactId>jaxb-core</artifactId>
	    <version>2.2.11</version>
	</dependency>
	<dependency>
	    <groupId>com.sun.xml.bind</groupId>
	    <artifactId>jaxb-impl</artifactId>
	    <version>2.2.11</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-xjc -->
	<dependency>
	    <groupId>com.sun.xml.bind</groupId>
	    <artifactId>jaxb-xjc</artifactId>
	    <version>2.2.11</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
	<dependency>
	    <groupId>javax.xml.ws</groupId>
	    <artifactId>jaxws-api</artifactId>
	    <version>2.2.11</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt -->
	<dependency>
	    <groupId>com.sun.xml.ws</groupId>
	    <artifactId>jaxws-rt</artifactId>
	    <version>2.2.10</version>
	    <type>pom</type>
	</dependency>
	<!-- https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-tools -->
	<dependency>
	    <groupId>com.sun.xml.ws</groupId>
	    <artifactId>jaxws-tools</artifactId>
	    <version>2.2.10</version>
	    <type>pom</type>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.glassfish.external/management-api -->
	<dependency>
	    <groupId>org.glassfish.external</groupId>
	    <artifactId>management-api</artifactId>
	    <version>3.2.1-b002</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/com.sun.xml.ws/policy -->
	<dependency>
	    <groupId>com.sun.xml.ws</groupId>
	    <artifactId>policy</artifactId>
	    <version>2.5</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.jvnet.staxex/stax-ex -->
	<dependency>
	    <groupId>org.jvnet.staxex</groupId>
	    <artifactId>stax-ex</artifactId>
	    <version>1.7.7</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.codehaus.woodstox/stax2-api -->
	<dependency>
	    <groupId>org.codehaus.woodstox</groupId>
	    <artifactId>stax2-api</artifactId>
	    <version>4.0.0</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/com.sun.xml.stream.buffer/streambuffer -->
	<dependency>
	    <groupId>com.sun.xml.stream.buffer</groupId>
	    <artifactId>streambuffer</artifactId>
	    <version>1.5.3</version>
	</dependency>
	
	<!-- 公共parent上的jar -->
	<!-- http://mvnrepository.com/artifact/org.springframework/spring-orm -->
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
	</dependency>
	<!-- http://mvnrepository.com/artifact/org.springframework/spring-context -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-context</artifactId>
	</dependency>
	<!-- http://mvnrepository.com/artifact/org.springframework/spring-orm -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-orm</artifactId>
	</dependency>
	<!-- http://mvnrepository.com/artifact/org.springframework/spring-orm -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-web</artifactId>
	    <version>3.2.1.RELEASE</version>
	</dependency>
	<!-- http://mvnrepository.com/artifact/org.springframework/spring-oxm -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-oxm</artifactId>
	</dependency>
	<!-- http://mvnrepository.com/artifact/org.springframework/spring-tx -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-tx</artifactId>
		<version>3.2.1.RELEASE</version>
	</dependency>
	<!-- http://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-jdbc</artifactId>
		<version>3.2.1.RELEASE</version>
	</dependency>
	<!-- http://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-webmvc</artifactId>
		<version>3.2.1.RELEASE</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-aop</artifactId>
	    <version>4.3.2.RELEASE</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-context-support</artifactId>
	    <version>4.3.2.RELEASE</version>
	</dependency>
	<!-- http://mvnrepository.com/artifact/org.springframework/spring-test -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-test</artifactId>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-core</artifactId>
	    <version>4.3.2.RELEASE</version>
	</dependency>
	<dependency>
		<groupId>com.caucho</groupId>
		<artifactId>hessian</artifactId>
		<version>4.0.38</version>
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
	<dependency>
	    <groupId>org.mybatis</groupId>
	    <artifactId>mybatis</artifactId>
	    <version>3.4.1</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
	<dependency>
	    <groupId>org.mybatis</groupId>
	    <artifactId>mybatis-spring</artifactId>
	    <version>1.3.0</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
	<dependency>
	    <groupId>org.mybatis.generator</groupId>
	    <artifactId>mybatis-generator-core</artifactId>
	    <version>1.3.4</version>
	</dependency>
	<!-- 导入java ee jar 包 -->  
	<dependency>  
        <groupId>javax</groupId>  
        <artifactId>javaee-api</artifactId>  
        <version>7.0</version>  
    </dependency> 
    <!-- 导入dbcp的jar包,用来在applicationContext.xml中配置数据库 -->  
    <dependency>  
        <groupId>commons-dbcp</groupId>  
        <artifactId>commons-dbcp</artifactId>  
        <version>1.2.2</version>  
    </dependency>  
	<!-- JSTL标签类 -->  
    <dependency>  
        <groupId>jstl</groupId>  
        <artifactId>jstl</artifactId>  
        <version>1.2</version>  
    </dependency>
    <!-- 日志 -->
    <dependency>
		<groupId>log4j</groupId>
		<artifactId>log4j</artifactId>
	</dependency>
	<!--格式化对象,方便输出日志 -->
	<dependency>
	    <groupId>com.alibaba</groupId>
	    <artifactId>fastjson</artifactId>
	    <version>1.2.16</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
	<dependency>
	    <groupId>org.slf4j</groupId>
	    <artifactId>slf4j-api</artifactId>
	    <version>1.7.21</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
	<dependency>
	    <groupId>org.slf4j</groupId>
	    <artifactId>slf4j-log4j12</artifactId>
	</dependency>
	<!-- 映入JSON -->  
    <dependency>  
        <groupId>org.codehaus.jackson</groupId>  
        <artifactId>jackson-mapper-asl</artifactId>  
        <version>1.9.13</version>  
    </dependency> 
    <!-- 上传组件包 -->  
     <dependency>  
         <groupId>commons-fileupload</groupId>  
         <artifactId>commons-fileupload</artifactId>  
         <version>1.3.1</version>  
     </dependency> 
     <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
	<dependency>
	    <groupId>commons-io</groupId>
	    <artifactId>commons-io</artifactId>
	    <version>2.5</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
	<dependency>
	    <groupId>commons-codec</groupId>
	    <artifactId>commons-codec</artifactId>
	    <version>1.10</version>
	</dependency>
	<dependency>
		<groupId>hw.hlatform.secg</groupId>
		<artifactId>secg-utils</artifactId>
	</dependency>
	<dependency>
		<groupId>hw.hlatform.secg</groupId>
		<artifactId>secg-pubilcinc</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</dependency>
  </dependencies>
  <build>
    <finalName>IHos-Api</finalName>
    <plugins>
    	<!-- 打成war包 -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-war-plugin</artifactId>
			<version>2.2</version>
			<configuration>
				<warName>IHos-Api</warName>
			</configuration>
		</plugin>
		<!-- 打成源码jar包 -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-source-plugin</artifactId>
		</plugin>
		<!-- jetty服务器 -->
		<plugin>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty-maven-plugin</artifactId>
			<configuration>
				<scanIntervalSeconds>10</scanIntervalSeconds>
				<contextXml>${project.basedir}/src/test/java/jetty-context.xml</contextXml>
				<webApp>
					<contextPath>/</contextPath>
				</webApp>
				<connectors>
					<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
						<port>8082</port>
						<maxIdleTime>60000</maxIdleTime>
					</connector>
				</connectors>
			</configuration>
		</plugin>
	</plugins>
	<!-- 目录各级的xml打包 -->
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.xml</include>
                <include>**/*.properties</include>
            </includes>
        </resource>
    </resources>
  </build>
</project>

 pom.xml里面有所需要的jar,打成jar的插件,打成war的插件,服务器jetty,引入各种文件的配置。

 

DAO层

 

package dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import model.pojo.Emp;

public interface EmpDao {
	public void addEmp(Emp emp); 
	public void updateEmp(Emp emp); 
	public void deleteEmp(int id); 
	public Emp getEmpById(@Param("empid") int empid);
	public List<Emp> list(Emp emp);
}

 DAO层实现

<?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="dao.EmpDao">
  <select id="getEmpById" parameterType="java.lang.Integer" resultType="model.pojo.Emp">
    select * from emp
    where empid = #{empid,jdbcType=INTEGER}
  </select>
  
  <delete id="deleteEmp" parameterType="java.lang.Integer">
    delete from emp where empid = #{empid,jdbcType=INTEGER}
  </delete> 
  
  <insert id="addEmp" parameterType="model.pojo.Emp">
    insert into emp (empid, name, age, 
      bir)
    values (#{empid,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER}, 
      #{bir,jdbcType=DATE})
  </insert>
  
  <update id="updateEmp" parameterType="model.pojo.Emp"> 
    update emp
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="age != null">
        age = #{age,jdbcType=INTEGER},
      </if>
      <if test="bir != null">
        bir = #{bir,jdbcType=DATE},
      </if>
    </set>
    where empid = #{empid,jdbcType=INTEGER} 
  </update>
</mapper>

 pojo层

package model.pojo;

import java.util.Date;

import model.pojo.base.BasePojo;

public class Emp extends BasePojo{
    private Integer empid;

    private String name;

    private Integer age;

    private Date bir;

    public Integer getEmpid() {
        return empid;
    }

    public void setEmpid(Integer empid) {
        this.empid = empid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Date getBir() {
        return bir;
    }

    public void setBir(Date bir) {
        this.bir = bir;
    }
}

 service层:

接口

package service.pojo;

import java.util.List;
import model.pojo.Emp;

public interface EmpService {
	public void addEmp(Emp emp); 
	public void updateEmp(Emp emp); 
	public void deleteEmp(int id); 
	public Emp getEmpById(int id);
	public List<Emp> list(Emp emp);
}

 实现:

package service.pojo.impl;  
  
import java.util.List;
import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import dao.EmpDao;
import model.pojo.Emp;
import service.pojo.EmpService;
  
@Service
public class EmpServiceImpl implements EmpService {  
    @Resource  
    private EmpDao empDao;

	@Override
	public void addEmp(Emp emp) {
		// TODO Auto-generated method stub
		empDao.addEmp(emp);
	}

	@Override
	public void updateEmp(Emp emp) {
		// TODO Auto-generated method stub
		empDao.updateEmp(emp);
	}

	@Override
	public void deleteEmp(int id) {
		// TODO Auto-generated method stub
		empDao.deleteEmp(id);
	}

	@Override
	public Emp getEmpById(int id) {
		// TODO Auto-generated method stub
		return empDao.getEmpById(id);
	}

	@Override
	public List<Emp> list(Emp emp) {
		// TODO Auto-generated method stub
//		return empDao.list(emp);
		return null;
	}  
}
   
  

 controller层

package controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import controller.base.BaseController;
import hw.hlatform.secg.pubilcinc.remoting.hessian.HessianDateService;
import model.pojo.Emp;
import service.pojo.EmpService;

@Controller
@RequestMapping("/emp")
public class EmpController extends BaseController {
	@Resource
	private EmpService empService;

	@Autowired
	private HessianDateService hessianDateService;

	@RequestMapping("/showEmp")
	public String toIndex(HttpServletRequest request, Model model) {
		 System.out.println("ok");
//		 int userId = Integer.parseInt(request.getParameter("id"));
//		 Emp emp = empService.getEmpById(userId);
//		 model.addAttribute("emp", emp);
//		 System.out.println(emp.getEmpid()+","+emp.getName()+","+emp.getBir()+","+emp.getBir());
		int i = Integer.parseInt(hessianDateService.getUserNum(null, null));
		System.out.println("------------------------------------");
		System.out.println(i);
		return "index";
	}
}

 jdbc.properties

数据库连接属性文件

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://218.12.10.26:20012/healthplat?useUnicode=true&characterEncoding=gbk&autoReconnect=true
username=bossadmin
password=orclboss
#定义初始连接数  
initialSize=0
#定义最大连接数  
maxActive=20
#定义最大空闲  
maxIdle=20
#定义最小空闲  
minIdle=1
#定义最长等待时间  
maxWait=60000

 log4j.properties

log4j.rootLogger=INFO,Console,File  
#定义日志输出目的地为控制台  
log4j.appender.Console=org.apache.log4j.ConsoleAppender  
log4j.appender.Console.Target=System.out  
#可以灵活地指定日志输出格式,下面一行是指定具体的格式  
log4j.appender.Console.layout = org.apache.log4j.PatternLayout  
log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n  
  
#文件大小到达指定尺寸的时候产生一个新的文件  
log4j.appender.File = org.apache.log4j.RollingFileAppender  
#指定输出目录  
log4j.appender.File.File = logs/ssm.log  
#定义文件最大大小  
log4j.appender.File.MaxFileSize = 10MB  
# 输出所以日志,如果换成DEBUG表示输出DEBUG以上级别日志  
log4j.appender.File.Threshold = ALL  
log4j.appender.File.layout = org.apache.log4j.PatternLayout  
log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n

 spring-mybatis.xml

<?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"  
    xmlns:mvc="http://www.springframework.org/schema/mvc"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans    
                        http://www.springframework.org/schema/beans/spring-beans-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.2.1.xsd">
    <!-- 自动扫描 -->  
    <context:component-scan base-package="service"/>
    <!-- 引入配置文件 -->  
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
        <property name="locations">
        	<list>  
              <value>classpath:jdbc.properties</value>  
              <value>classpath:config.properties</value>  
         	</list>
        </property>  
    </bean>
  	<!-- 配置数据源 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">  
        <property name="driverClassName" value="${driver}" />  
        <property name="url" value="${url}" />  
        <property name="username" value="${username}" />  
        <property name="password" value="${password}" />  
		<!--初始化连接大小   -->
        <property name="initialSize" value="${initialSize}"></property>  
		<!--连接池最大数量   -->
        <property name="maxActive" value="${maxActive}"></property>  
		<!--连接池最大空闲   -->
        <property name="maxIdle" value="${maxIdle}"></property>  
		<!--连接池最小空闲   -->
        <property name="minIdle" value="${minIdle}"></property>  
		<!--获取连接最大等待时间   -->
        <property name="maxWait" value="${maxWait}"></property>  
    </bean>  
  
    <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->  
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
        <property name="dataSource" ref="dataSource" />  
		<!--自动扫描mapping.xml文件   -->
        <property name="mapperLocations" value="classpath:dao/*.xml"></property>
    </bean>  
  
    <!-- DAO接口所在包名,Spring会自动查找其下的类,为其实例化dao接口,实例化xml文件进行实例化的 -->  
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
        <property name="basePackage" value="dao"/>
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>  
    </bean>  
  
    <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->  
<!--     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   -->
<!--         <property name="dataSource" ref="dataSource" />   -->
<!--     </bean>   -->
</beans>  

 spring-mvc.xml

<?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"  
    xmlns:mvc="http://www.springframework.org/schema/mvc"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans    
                        http://www.springframework.org/schema/beans/spring-beans-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-4.0.xsd">  
    <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 -->  
    <context:component-scan base-package="controller" />  
    <!--避免IE执行AJAX时,返回JSON出现下载文件 -->  
    <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">  
        <property name="supportedMediaTypes">  
            <list>  
                <value>text/html;charset=UTF-8</value>  
            </list>  
        </property>  
    </bean>  
    <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->  
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">  
        <property name="messageConverters">  
            <list>  
                <ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 -->  
            </list>  
        </property>  
    </bean>  
	
	<!-- 对webapp下的静态资源可以直接访问 -->    
    <mvc:resources location="/upload/" mapping="/upload/**" />  
    <!-- 定义跳转的文件的前后缀 ,视图模式配置-->  
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
        <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 -->  
        <property name="prefix" value="/WEB-INF/jsp/" />  
        <property name="suffix" value=".jsp" />  
    </bean>  
      
    <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 -->  
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">    
        <!-- 默认编码 -->  
        <property name="defaultEncoding" value="utf-8" />    
        <!-- 文件大小最大值 -->  
        <property name="maxUploadSize" value="10485760000" />    
        <!-- 内存中的最大值 -->  
        <property name="maxInMemorySize" value="40960" />    
    </bean>   
    <!-- 配置工具类获取spring的上下文环境 -->
    <bean id="springContextUtil" class="util.SpringContextUtil" scope="singleton"/>
</beans>  

 

页面这块就先不写了,随便写个简单的测试就可以了。

 

 

分享到:
评论

相关推荐

    ssm搭建redis环境

    本教程将详细讲解如何利用SSM搭建一个支持Redis的开发环境,并探讨如何在集群模式下运行。 首先,我们从SSM框架开始。SSM是三个开源Java框架——Spring、SpringMVC和MyBatis的组合,用于构建高效、灵活的Web应用。...

    ssm搭建的web项目

    综上所述,"ssm搭建的web项目"是一个涵盖了Spring、Spring MVC和MyBatis的完整Web应用实例,涉及了数据库设计、业务逻辑处理、Web请求响应等多个方面,是学习和实践Java Web开发的好素材。通过运行这个项目,可以...

    ssm搭建的商城

    这个“ssm搭建的商城”项目显然使用了这些技术来创建一个电子商务平台。下面我们将详细探讨SSM框架的核心组件以及在搭建商城系统中的应用。 **1. Spring框架** Spring是Java企业级应用的核心框架,它提供了全面的...

    ssm搭建与实例

    ssm搭建及实例demo 开发环境:eclipse+maven spring + springmvc + mybatis 分页插件pagehelper

    java开发课程设计SSM搭建的图书管理系统项目源代码.zip

    java开发课程设计SSM搭建的图书管理系统源代码。这个项目是基于springmvc mybatis 框架前端使用jsp+layui前端模板搭建而成实现了用户注册/登录和增删改查还有书籍的增删改查.是个应付课设的万能模板!java开发课程...

    基于SSM搭建的点餐系统(前台+后台).zip

    本项目"基于SSM搭建的点餐系统(前台+后台).zip"提供了一个完整的点餐系统的实现,适合计算机专业的学生进行毕业设计或课程设计学习。 首先,Spring框架作为核心,负责管理应用程序的组件,通过依赖注入(DI)来...

    简单的SSM搭建demo

    这个“简单的SSM搭建demo”旨在帮助开发者快速理解并实践SSM框架的集成与应用。 首先,Spring框架是整个SSM的核心,它提供了依赖注入(Dependency Injection,DI)和面向切面编程(Aspect-Oriented Programming,...

    SSM搭建的简单示例

    这个"SSM搭建的简单示例"旨在介绍如何将这三个框架整合在一起,构建一个基本的Web应用程序。下面我们将深入探讨SSM框架的各个组成部分以及它们在实际项目中的作用。 首先,Spring框架是核心,它提供了依赖注入...

    SSM搭建jar包

    SSM框架是Java Web开发中常用的...这个压缩包提供的SSM相关jar包是搭建SSM环境的基础,结合合适的数据库驱动,你就可以开始构建和运行你的Java Web应用了。在实际开发过程中,还需要根据项目需求进行适当的调整和优化。

    SSM搭建的商城毕业设计附带论文与设计文档,导入后即可使用

    本项目基于SSM框架搭建了一个完整的在线商城系统,适用于毕业设计或教学实践,提供了一整套从需求分析到实际运行的解决方案。 首先,Spring框架作为基础,它主要负责依赖注入(DI)和面向切面编程(AOP)。DI允许...

    ssm搭建需要的可以看看.txt

    ssm搭建

    ssm搭建环境教案

    这个“ssm搭建环境教案”应该包含如何配置和整合这三个组件来创建一个完整的开发环境的步骤。下面将详细讲解SSM框架的核心概念、配置过程以及整合技巧。 **Spring框架**:Spring是Java企业级应用的核心框架,提供了...

    SSM搭建所需Jar包

    本文将详细解析这些组件以及相关Jar包在SSM搭建中的作用。 首先,Spring是Java企业级应用的核心框架,它提供了一个全面的编程和配置模型,用于简化企业级应用程序的开发。Spring 4.1.6版本在此基础上提供了依赖注入...

    SSM搭建好的框架.zip

    在这个"SSM搭建好的框架.zip"中,我们看到已经预先配置了一个基于Spring 5、MyBatis 3和Maven的项目结构。下面我们将详细探讨这些关键组件及其相互作用。 1. **Spring框架**: Spring是一个开源的Java平台,它提供...

    Eclipse+Maven+SSM搭建

    总结来说,Eclipse+Maven+SSM搭建是一个常见的Java Web项目开发流程,它结合了强大的IDE、高效的构建工具和灵活的框架,为开发者提供了一套高效、便捷的开发环境。通过学习这个搭建过程,开发者不仅能掌握基本的项目...

    ssm搭建项目框架(spring+springmvc+mybatis)有easyUI

    ssm搭建项目框架(spring+springmvc+mybatis)有easyUI

    SSM搭建的简单电商网站

    这个"SSM搭建的简单电商网站"项目,通过整合这三大框架,构建了一个基本的在线购物平台。下面我们将深入探讨SSM框架以及它们在电商网站中的应用。 1. **Spring框架**:Spring作为核心容器,负责管理对象的生命周期...

    SSM搭建参考项目

    这个"SSM搭建参考项目"旨在为开发者提供一个基础的SSM整合实例,帮助理解并掌握这三大框架的协同工作原理。 Spring作为核心容器,负责管理对象(Bean)及其依赖关系,通过IoC(Inversion of Control,控制反转)和...

    ssm搭建框架实现登陆 注册

    本项目通过SSM搭建的框架实现登录、注册功能,并包含修改密码和个人信息的系统。 1. **Spring框架**:Spring是核心容器,管理应用程序的组件,提供依赖注入(DI)和面向切面编程(AOP)。在登录注册系统中,Spring...

    #ssm 搭建笔记.md

    #ssm 搭建笔记.md

Global site tag (gtag.js) - Google Analytics