spring+spring4 mybatis3 做app服务端可以吗

Spring3+MyBatis 整合多方法使用 -
- ITeye技术网站
& web.xml配置文件
&?xml version="1.0" encoding="UTF-8"?&
&web-app version="2.5"
xmlns="/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="/xml/ns/javaee
/xml/ns/javaee/web-app_2_5.xsd"&
&display-name&&/display-name&
&welcome-file-list&
&welcome-file&/WEB-INF/view/welcome.jsp&/welcome-file&
&/welcome-file-list&
&!-- 配置加载Spring配置文件路径 --&
&context-param&--&
&param-name&contextConfigLocation&/param-name&--&
&param-value&/WEB-INF/applicationContext.xml&/param-value&--&
&/context-param&--&
默认的spring配置文件是在WEB-INF下的applicationContext.xml
Spring 容器启动监听器
&listener&
&listener-class&org.springframework.web.context.ContextLoaderListener&/listener-class&
&/listener&
&!-- 配置字符过滤器 --&
&filter-name&Set Character Encoding&/filter-name&
&filter-class&org.springframework.web.filter.CharacterEncodingFilter&/filter-class&
&init-param&
&param-name&encoding&/param-name&
&param-value&UTF-8&/param-value&
&/init-param&
&init-param&
&param-name&forceEncoding&/param-name&
&param-value&true&/param-value& &!-- 强制进行转码 --&
&/init-param&
&filter-mapping&
&filter-name&Set Character Encoding&/filter-name&
&url-pattern&/*&/url-pattern&
&/filter-mapping&
&!-- 配置 Spring view分发器 --&
&servlet-name&dispatcher&/servlet-name&
&servlet-class&org.springframework.web.servlet.DispatcherServlet&/servlet-class&
&!-- 配置初始配置化文件,前面contextConfigLocation看情况二选一 --&
&init-param&
&param-name&contextConfigLocation&/param-name&
&param-value&
/WEB-INF/applicationContext.xml,
/WEB-INF/config/dispatcher-servlet.xml
&/param-value&
&/init-param&
&!-- 启动加载一次 --&
&load-on-startup&1&/load-on-startup&
&/servlet&
&servlet-mapping&
&servlet-name&dispatcher&/servlet-name&
&!-- 这里可以用 / 但不能用 /* ,拦截了所有请求会导致静态资源无法访问
&url-pattern&/&/url-pattern&
&/servlet-mapping&
&!-- 设置session超时 --&
&session-config&
&session-timeout&30&/session-timeout&
&/session-config&
&!-- 配置异常页面 --&
&error-page&
&error-code&404&/error-code&
&location&/error_page.jsp&/location&
&/error-page&
&error-page&
&error-code&500&/error-code&
&location&/error_page.jsp&/location&
&/error-page&
&!-- 配置要使用到的标签 --&
&jsp-config&
&taglib-uri&http://www.springframework.org/tags&/taglib-uri&
&taglib-location&/WEB-INF/tld/spring.tld&/taglib-location&
&taglib-uri&/jsp/jstl/core&/taglib-uri&
&taglib-location&/WEB-INF/tld/c.tld&/taglib-location&
&/jsp-config&
&/web-app&
applicationContext.xml Spring配置文件
&?xml version="1.0" encoding="UTF-8" standalone="no"?&
&beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" default-autowire="byName"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"&
&!-- 加载读取properties配置文件参数 --&
&bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&
&property name="location"&
&value&/WEB-INF/jdbc.properties&/value&
&/property&
&!-- 导入属性配置文件 --&
&!--& context:property-placeholder
location = "classpath:jdbc.properties"
&!-- 配置数据库连接池,使用dbcp --&
&bean id="dataSource" class="mons.dbcp.BasicDataSource" destroy-method="close"&
&property name="driverClassName" value="${jdbc.driverClassName}"&&/property&
&property name="url" value="${jdbc.databaseurl}"&&/property&
&property name="username" value="${jdbc.username}"&&/property&
&property name="password" value="${jdbc.password}"&&/property&
&!-- 连接池启动时的初始值 --&
&property name="initialSize" value="1" /&
&!-- 连接池的最大值 --&
&property name="maxActive" value="500" /&
&!-- 最大空闲值.当经过一个高峰时间后,
连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止
&property name="maxIdle" value="2" /&
&!-- 最小空闲值.当空闲的连接数少于阀值时,
连接池就会预申请去一些连接,以免洪峰来时来不及申请 --&
&property name="minIdle" value="1" /&
&!-- MyBatis定义数据源,同意加载配置 --&
&bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&
&property name="configLocation" value="/WEB-INF/config/mybatis_config.xml" /&
&property name="dataSource" ref="dataSource" /&
&!-- &property name="mapperLocations" value="classpath*:mappers-*.xml" /& --&
&bean id="userInfoDao" class="org.mybatis.spring.mapper.MapperFactoryBean"&
&property name="mapperInterface" value="com.skillmuster.core.dao.UserMapper" /&
&property name="sqlSessionFactory" ref="sqlSessionFactory" /&
&!-- 可配置多个这样的接口映射 --&
&!--&bean id="userInfoDao" class="org.mybatis.spring.mapper.MapperFactoryBean"&--&
&!-- &property name="mapperInterface" value="com.skillmuster.core.dao.UserMapper2" /&--&
&!-- &property name="sqlSessionFactory" ref="sqlSessionFactory" /&--&
&!--&/bean&--&
&!-- MyBatis 映射配置,如果接口和mybatis映射文件在同一路径下且命名相同,可采用自动扫描包的方式来注册各种Mapper --&
&!--&bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"&--&
&!-- &property name="basePackage" value="com.skillmuster.core.dao"/&--&
&!-- markerInterface接口的子接口都参与到这个扫描
&property name="markerInterface" value="com.skillmuster.cor.dao.UserMapper" /& --&
&!--&/bean&--&
&!-- 配置事物管理
&bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&
&property name="dataSource" ref="dataSource" /&
&!-- 申明事务通知 --&
&tx:advice id="txAdivice" transaction-manager="transactionManager"&
&tx:attributes&
&tx:method name="insert*"
isolation="READ_COMMITTED"
propagation="REQUIRED"
rollback-for="Exception" /&
&tx:method name="query*"
propagation="NOT_SUPPORTED"
isolation="DEFAULT"
rollback-for="java.io.IOException"
no-rollback-for="java.lang.ArithmeticException,java.lang.*"
timeout="30"
read-only="true" /&
&/tx:attributes&
&/tx:advice&
&!-- 将通知和切入点联接 --&
&aop:config&
&!-- 分开配置 --&
&!-- &aop:pointcut expression="execution(* com.iss.is.service.impl..*.*(..))" id="allServiceMethod" /& --&
&!-- &aop:advisor advice-ref="txAdivice" pointcut-ref="allServiceMethod" /&--&
&!-- 一起配置 --&
&!-- &aop:advisor advice-ref="txAdivice" pointcut="exection(* com.skillmuster.core.service.*ServiceImpl.*(..))" /&--&
&/aop:config&
& dispatcher-servlet Spring MVC配置文件
&?xml version="1.0" encoding="UTF-8"?&
&beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd" default-autowire="byName"&
&!-- default-autowire="byName",约定优于配置 --&
&!-- @Controller 请求映射注解扫描,必须加上这个,不然请求controller时会出现no mapping url错误--&
&mvc:annotation-driven /&
&!-- 配置静态资源,直接映射到对应的文件夹,不被DispatcherServlet处理,3.04新增功能,需要重新设置spring-mvc-3.0.xsd --&
&mvc:resources mapping="/img/**" location="/img/"/&
&mvc:resources mapping="/js/**" location="/js/"/&
&mvc:resources mapping="/css/**" location="/css/"/&
&mvc:resources mapping="/html/**" location="/html/"/&
①:注解扫描,对包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能
&context:component-scan base-package="com.skillmuster.core" /&
②:启动Spring MVC的注解功能,完成请求和注解POJO的映射,//添加拦截器,类级别的处理器映射
&!-- &bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"& --&
&property name="interceptors"&--&
&bean class="com.fsj.spring.util.MyHandlerInterceptor"/&--&
&/list&--&
&/property&--&
&!-- &property name="order"&&value&1&/value&&/property& --&
&!-- &/bean& --&
&!-- &bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"& --&
&property name="cacheSeconds" value="0" /&
&!-- 配置一下对json数据的转换 --&
&property name="messageConverters"&--&
&bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"&&/bean&--&
&/list&--&
&/property&--&
&!-- &/bean& --&
③:对模型视图名称的解析,即在模型视图名称添加前后缀
InternalResourceViewResolver默认的就是JstlView所以这里就不用配置viewClass了
&bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&
p:prefix="/WEB-INF/view/" p:suffix=".jsp" /&--&
&property name="prefix" value="/WEB-INF/view/" /&
&property name="suffix" value=".jsp" /&
&!-- spring2.0的配置处理方式 --&
&!-- 处理器映射,它将收到的HTTP请求映射到bean的名字上 --&
&bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"&--&
&property name="order"&&value&1&/value&&/property&--&
&/bean&--&
&!-- 视图解析器 --&
&bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&--&
&property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /&--&
&property name="contentType"&--&
&value&text/charset=UTF-8&/value&--&
&/property&--&
页面路径 --&
&property name="prefix" value="/WEB-INF/pages/" /&--&
&property name="suffix" value=".jsp" /&--&
Controller配置
&bean name="/saveStudent.do" class="com.iss.is.web.controller.demo.student.SaveStudentController"&--&
&property name="studentService"&--&
&ref local="studentService"/&--&
&/property&--&
&property name="commandClass"&--&
&value&com.iss.is.dto.StudentDTO&/value&--&
&/property&--&
&!-- &/bean& --&
& jdbc.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.databaseurl=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=123
mybatis-config.xml MyBatis总配置文件
&?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&
&!-- 实体类,简称
&typeAliases&
&typeAlias alias="userinfo" type="com.skillmuster.core.pojo.User" /&
&/typeAliases&
&!-- 实体接口映射资源 --&
&mapper resource="com/skillmuster/core/dao/UserMapper.xml"/&
&/mappers&
&/configuration&
UserMapper.xml
&?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="com.skillmuster.core.dao.UserMapper"&
&resultMap type="userinfo" id="userResultMap"&
&id property="id" column="id" /&
&result property="username" column="username" /&
&result property="password" column="password" /&
&/resultMap&
&insert id="insertUser" parameterType="userinfo"&
insert into user(username,password) values(#{username},#{password})
&!-- mybsits_config中配置的alias类别名,也可直接配置resultType为类路劲 --&
&select id="getUser" resultType="userinfo"&
select * from user
&!-- 当使用该Mybatis与Spring整合的时候,该文件必须和相应的Mapper接口文件同名,并在同一路径下 --&
UserMapper 映射接口
public interface UserMapper {
void insertUser(User user);
List&User& getUser();
浏览: 61023 次
来自: 湖南
报错了 楼主 Exception in thread &quo ...
挺好的 正好拿来用用
你好,我也遇到同样的问题,而且次问题只在ie上面才会出现,请问 ...用心创造滤镜
扫码下载App
汇聚2000万达人的兴趣社区下载即送20张免费照片冲印
扫码下载App
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
杨朱/子产/郗鉴/韦叡/王守仁
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
2. &&Ambiguous mapping found when using class multi level @RequestMapping urls这个是spring mvc的url映射重复了3. &Jackson 报错:Infinite recursion (StackOverflowError)json支持使用Jackson包,出现如上错误,有说解决方法是:在返回对象的entity中找到有关联关系的对象,在其get方法上加入&@JsonBackReference尝试下,无效。controller里返回值是map中还有个map,也许是这个错。后来用自定义的dto对象全部封装起来,就没这个错了。以下两点参考文档:/springside/springside4/wiki/SpringMVC4. 事务保证spring-mvc.xml的context:component-scan只扫描Controller,而 applicationContext.xml里的不包含Controller. 否则在applicationContext.xml里的事务就要失效了。方法如下:spring-mvc.xml:&context:component-scan base-package="com.mycompany.myproject" use-default-filters="false"& &context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/&&/context:component-scan&applicationContext.xml:&context:component-scan base-package="org.springside.examples.quickstart"& &context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/&&/context:component-scan&另外,定义在spring-mvc.xml里的东西,在applicationContext*.xml中是不可见的,想共享的东西最好放在applicationContext.xml那边。而applicationContext*.xml里的一些BeanPostProccesor,也不会作用到spring-mvc.xml定义/扫描到的Bean上,如果有必要就在spring-mvc.xml里重新定义一次,像Shiro的AOP校验权限。还有另一种方法,就是全部在spring mvc的配置文件里进行配置。关于applicationContext.xml和&spring-mvc&.xml文件内容不共享的问题稍后作详细介绍。5.&Preparable接口--表单仅包含对象领域部分属性Struts2有一个很实用的Preparable二次绑定功能: 表单提交时,先绑定一个ID,使用这个ID从数据库里找出对象来,再把表单中的其他属性绑定到这个对象上,对于那些表单中的输入框数量比业务对象的实际属性数少的情况很实用。其实Spring MVC也有相同的能力, 见quickstart中的UserAdminController.先用@ModelAttribute标注如下函数。SpringMVC会在执行任何实际处理函数之前,执行该函数并将返回值存为Model Attribute "user"@ModelAttribute("user")public User getUser(@RequestParam(value = "id", required = false) Long id) { if (id != null) {
return accountService.getUser(id); } }再在save函数里,以@ModelAttribute标注表单处理函数的参数。SpringMVC就会按名称"user"取出前面的对象,然后才进行真正的Binding。@RequestMapping(value = "update/{userId}", method = RequestMethod.POST)public String update(@Valid @ModelAttribute("user") User user) { accountService.updateUser(user); return "redirect:/admin/user";}注意1, 这里有个小坑爹的地方是,这个getUser()会在controller的所有函数前都执行,因此需要进行一下判断RequestParam中是否含id属性的判断,要不你就把update()方法独立到一个Controller中。注意2, ModelAttribute如果已经占用了"user"这个名字,那些非update()函数的参数里就要躲开这个名字。6. cookie报错java.lang.IllegalArgumentException: Control character in cookie value, consider BASE64 encoding your valuecookies只支持ASCII字符,而且不能有逗号,分号,空白。或者以$开头。名字在创建后不能改变。如果要存储中文的,先用URLEcode编码,在存入,取出的时候,用decode解码。7. &在web容器里保存applicationContext建一个listener配置到web.xml中去import javax.servlet.ServletCimport javax.servlet.ServletContextEimport javax.servlet.ServletContextLimport org.springframework.context.ApplicationCimport org.springframework.web.context.support.WebApplicationContextUpublic class WebAppContextListener implements ServletContextListener { public void contextDestroyed(ServletContextEvent event) {} public void contextInitialized(ServletContextEvent event) {
ApplicationContext cxt = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
Const.WEB_APP_CONTEXT = }}8. &以上是applicationContext.xml文件对应的context,获取&spring-mvc&.xml文件对应的context需使用ApplicationContext applicatinContext = RequestContextUtils.getWebApplicationContext(request);关于这两个context的区别,这里有描述:/blog/1107036spring通过在web.xml 中配置ContextLoaderListener 来加载context配置文件,在DispatcherServlet中也可以来加载spring context配置文件,那么这两个有什么区别呢。&ContextLoaderListener中加载的context成功后,spring 将 applicationContext存放在ServletContext中key值为"org.springframework.web.context.WebApplicationContext.ROOT"的attribute中。(servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context));可以通过WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext)或WebApplicationContextUtils.getWebApplicationContext(servletContext)方法来获取对应的applicationContext。&DispatcherServlet加载的context成功后,如果 publishContext属性的值设置为true的话(缺省为true) 会将applicationContext存放在org.springframework.web.servlet.FrameworkServlet.CONTEXT. + (servletName)的attribute中。&例如 web.xml中配置如下&&servlet& && & &servlet-name&mvcServlet&/servlet-name& && & &servlet-class&org.springframework.web.servlet.DispatcherServlet&/servlet-class& && & &init-param& && & & & &param-name&contextConfigLocation&/param-name& && & & & &param-value&classpath*:/spring/config/applicationContextMVC.xml&/param-value& && & &/init-param& && & &load-on-startup&1&/load-on-startup& &&/servlet& &则对应的applicationContext的attribute key值为org.springframework.web.servlet.FrameworkServlet.CONTEXT.mvcServlet。&& 在每次request请求时,DispatcherServlet会将此applicationContext存放在request中attribute值为 org.springframework.web.servlet.DispatcherServlet.CONTEXT中(request.setAttribute(WEB_APPLICATION_CONTEXT_ATTRIBUTE,getWebApplicationContext());)。可以通过 RequestContextUtils.getWebApplicationContext 或 WebApplicationContextUtils.getWebApplicationContext(servletContext,attrname)方法 来获取对应的applicationContext。&& 从上面的分析可以看出,DispatcherServlet所加载的applicationContext可以认为是mvc私有的context,由于保存在servletContext中的key值与通过ContextLoaderListener加载进来的applicationContext使用的key值不相同,因此如果只使用DispatcherServlet加载context的话,如果程序中有地方使用WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext) 来试图获取applicationContext时,就会抛出"No WebApplicationContext found: no ContextLoaderListener registered?"的exception。9. json view的配置& & &bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"&& & & & &property name="contentNegotiationManager"&&& & & & & & &bean class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"& & & & & & & & & p:favorPathExtension="false"& & & & & & & & & p:favorParameter="true"& & & & & & & & & p:parameterName="format"& & & & & & & & & p:ignoreAcceptHeader="true"& & & & & & & & & p:defaultContentType="text/html"&& & & & & & & & &property name="mediaTypes"&& & & & & & & &
&props&& & & & & & & &
&prop key="xml"&application/xml&/prop&& & & & & & & &
&prop key="json"&application/json&/prop&& & & & & & & &
&/props&& & & & & & & &
&!-- &value&& & & & & & & &
xml=application/xml& & & & & & & &
json=application/json& & & & & & & &
&/value&& & & & & & & & & & &map&& & & & & & & & & & & & &entry key="xml" value="application/xml"/&& & & & & & & & & & & & &entry key="json" value="application/json"/&& & & & & & & & & & &/map& --&& & & & & & & & &/property&& & & & & & &/bean&& & & & &/property&& & & & &property name="viewResolvers"&& & & & & & &list /&& & & & &/property& & & & && & & & &property name="defaultViews"& && & & & & & &list& && & & & & & & & &ref bean="marshallingView" /&& & & & & & & & &ref bean="mappingJacksonJsonView" /&& & & & & & &/list&& & & & &/property&& & &/bean&& & &bean id="marshallingView" class="org.springframework.web.servlet.view.xml.MarshallingView"& && & & & &property name="marshaller"& && & & & & & &bean class="org.springframework.oxm.xstream.XStreamMarshaller"/& && & & & &/property&& & & & &property name="modelKey" value="model" /&& & &/bean&& & &bean id="mappingJacksonJsonView" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /&其中props那段配置跟注释掉的内容是一致的,配置方式不同而已。& & & 还有另外的配置方式& &&&mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"&& &
&mvc:message-converters&& &
&bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"&
& & & & & &&property name="objectMapper" ref="jacksonObjectMapper" /&
& & & &&/bean&& &
&/mvc:message-converters&& & &/mvc:annotation-driven&或者 &mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/& &bean id="contentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"&
&property name="favorPathExtension" value="false" /&
&property name="favorParameter" value="false" /&
&property name="ignoreAcceptHeader" value="false" /&
&property name="mediaTypes"&
xml=application/xml& & & & json=application/json
&/property& &/bean&10.&&Invalid bound statement (not found): com.....UserDao.getUser出现这个错误是sql映射文件不存在,或sql映射有错误。11. 数字验证Double myNumber=2323;Double test=0.3434;//getInstance()//返回当前缺省语言环境的缺省数值格式。String myString = NumberFormat.getInstance().format(myNumber);System.out.println(myString);//getCurrencyInstance()返回当前缺省语言环境的通用格式myString = NumberFormat.getCurrencyInstance().format(myNumber);System.out.println(myString);//getNumberInstance() 返回当前缺省语言环境的通用数值格式。myString = NumberFormat.getNumberInstance().format(myNumber);System.out.println(myString);//getPercentInstance() &返回当前缺省语言环境的百分比格式。myString = NumberFormat.getPercentInstance().format(test);System.out.println(myString);//setMaximumFractionDigits(int) 设置数值的小数部分允许的最大位数。//setMaximumIntegerDigits(int) &设置数值的整数部分允许的最大位数。//setMinimumFractionDigits(int) 设置数值的小数部分允许的最小位数。//setMinimumIntegerDigits(int) &设置数值的整数部分允许的最小位数.NumberFormat format = NumberFormat.getInstance();format.setMinimumFractionDigits( 3 );format.setMaximumFractionDigits(5);format.setMaximumIntegerDigits( 10 );format.setMinimumIntegerDigits(0);System.out.println(format.format(.));12.&java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/SgetContextPath()方法在servlet 2.5版本才有,因此对于servlet-api的依赖不要写成2.3,有时候有些包没有直接依赖servlet-api 2.3,比如axis,这时就需要排除axis中对于servlet-api 2.3的依赖。
阅读(4001)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'一个spring mvc + mybatis项目里的一些问题',
blogAbstract:'1. &&mybatis sql 映射配置文件里的sql语句,如果没有把最后的;号去掉,会报错ORA-00911: 无效字符2. &&Ambiguous mapping found when using class multi level @RequestMapping urls这个是spring mvc的url映射重复了3. &Jackson 报错:Infinite recursion (StackOverflowError)json支持使用',
blogTag:'spring,mvc,mybatis',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:2,
publishTime:6,
permalink:'blog/static/',
commentCount:3,
mainCommentCount:2,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:true,
hostIntro:'杨朱/子产/郗鉴/韦叡/王守仁',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 spring boot mybatis 的文章

 

随机推荐