diff --git a/pom.xml b/pom.xml index ae69aa8e..302e3215 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ 1.7 - 4.2.6.RELEASE + 4.3.2.RELEASE 1.2.5 1.7.16 1.1.5 diff --git a/src/main/java/com/smallchill/core/base/controller/BladeController.java b/src/main/java/com/smallchill/core/base/controller/BladeController.java index 31b70e4d..37c93a2a 100644 --- a/src/main/java/com/smallchill/core/base/controller/BladeController.java +++ b/src/main/java/com/smallchill/core/base/controller/BladeController.java @@ -38,7 +38,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; import com.smallchill.common.vo.ShiroUser; import com.smallchill.core.constant.Const; @@ -89,10 +88,7 @@ public class BladeController implements ConstCurd, ConstCache{ String msg = ex.getMessage(); Object resultModel = null; try { - if (ex.getClass() == NoSuchRequestHandlingMethodException.class) { - url = Const.error404Path; - msg = ConstShiro.NO_METHOD; - } else if (ex.getClass() == HttpRequestMethodNotSupportedException.class) { + if (ex.getClass() == HttpRequestMethodNotSupportedException.class) { url = Const.error500Path;// 请求方式不允许抛出的异常,后面可自定义页面 } else if (ex.getClass() == NoPermissionException.class) { url = Const.noPermissionPath;// 无权限抛出的异常 diff --git a/src/main/java/com/smallchill/core/exception/HandlerException.java b/src/main/java/com/smallchill/core/exception/HandlerException.java index 2c36ccda..b1f29d80 100644 --- a/src/main/java/com/smallchill/core/exception/HandlerException.java +++ b/src/main/java/com/smallchill/core/exception/HandlerException.java @@ -26,7 +26,6 @@ import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; import com.smallchill.common.vo.ShiroUser; import com.smallchill.core.base.controller.BladeController; @@ -53,10 +52,7 @@ public class HandlerException { try { String header = request.getHeader("X-Requested-With"); boolean isAjax = "XMLHttpRequest".equalsIgnoreCase(header); - if (ex.getClass() == NoSuchRequestHandlingMethodException.class) { - url = Const.error404Path; - msg = ConstShiro.NO_METHOD; - } else if (ex.getClass() == HttpRequestMethodNotSupportedException.class) { + if (ex.getClass() == HttpRequestMethodNotSupportedException.class) { url = Const.error500Path;// 请求方式不允许抛出的异常,后面可自定义页面 } else if (ex.getClass() == NoPermissionException.class) { url = Const.noPermissionPath;// 无权限抛出的异常 diff --git a/src/main/java/com/smallchill/core/toolbox/Maps.java b/src/main/java/com/smallchill/core/toolbox/Maps.java deleted file mode 100644 index 1273204b..00000000 --- a/src/main/java/com/smallchill/core/toolbox/Maps.java +++ /dev/null @@ -1,326 +0,0 @@ -package com.smallchill.core.toolbox; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.sql.Time; -import java.sql.Timestamp; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; - -import com.smallchill.core.modules.support.Conver; -import com.smallchill.core.toolbox.kit.BeanKit; - -/** - * 扩充了HashMap中的方法 - * - * @author loolly, chill - * - */ -@SuppressWarnings("serial") -public class Maps extends HashMap { - - private String tableName; - private String pkName; - - public String getTableName() { - return tableName; - } - - public Maps setTableName(String tableName) { - this.tableName = tableName; - return this; - } - - public String getPkName() { - return pkName; - } - - public Maps setPkName(String pkName) { - this.pkName = pkName; - return this; - } - - /** - * 创建Maps - * @return Maps - */ - public static Maps create() { - return new Maps(); - } - - /** - * 创建Maps - * @param tableName 表名 - * @param pkName 主键名 - * @return Maps - */ - public static Maps create(String tableName, String pkName) { - return new Maps(tableName, pkName); - } - - private Maps(){ - - } - - private Maps(String tableName, String pkName){ - this.tableName = tableName; - this.pkName = pkName; - } - - /** - * 创建HashMap - * - * @return HashMap - */ - public static HashMap createHashMap() { - return new HashMap<>(); - } - - /** - * 将PO对象转为Maps - * @param - * @param bean Bean对象 - * @return Vo - */ - public static Maps parse(T bean) { - return create().parseBean(bean); - } - - /** - * 将map对象转为Maps - * - * @param - * @param vo - * 值对象 - * @return Vo - */ - public static Maps parse(Map map) { - return create().parseMap(map); - } - - - /** - * 转换为Bean对象 - * @param - * @param bean Bean - * @return Bean - */ - public T toBean(T bean) { - BeanKit.fillBeanWithMap(this, bean); - return bean; - } - - /** - * 填充Value Object对象 - * @param clazz Value Object(或者POJO)的类 - * @return vo - */ - public T toBean(Class clazz) { - return BeanKit.mapToBean(this, clazz); - } - - /** - * 填充Value Object对象,忽略大小写 - * @param clazz Value Object(或者POJO)的类 - * @return vo - */ - public T toBeanIgnoreCase(Class clazz) { - return BeanKit.mapToBeanIgnoreCase(this, clazz); - } - - /** - * 将值对象转换为Maps
- * 类名会被当作表名,小写第一个字母 - * @param - * @param bean 值对象 - * @return 自己 - */ - public Maps parseBean(T bean) { - this.putAll(BeanKit.beanToMap(bean)); - return this; - } - - /** - * 将值对象转换为Maps
- * 类名会被当作表名,小写第一个字母 - * - * @param - * @param map - * 值对象 - * @return 自己 - */ - public Maps parseMap(Map map) { - this.putAll(map); - return this; - } - - /** - * 与给定实体对比并去除相同的部分
- * 此方法用于在更新操作时避免所有字段被更新,跳过不需要更新的字段 - * version from 2.0.0 - * @param Maps - * @param withoutNames 不需要去除的字段名 - */ - public void removeEqual(T map, String... withoutNames) { - HashSet withoutSet = new HashSet(); - for (String name : withoutNames) { - withoutSet.add(name); - } - - for(Entry entry : map.entrySet()) { - if(withoutSet.contains(entry.getKey())) { - continue; - } - - final Object value = this.get(entry.getKey()); - if(null != value && value.equals(entry.getValue())) { - this.remove(entry.getKey()); - } - } - } - - //-------------------------------------------------------------------- 特定类型值 - /** - * 设置列 - * @param attr 属性 - * @param value 值 - * @return 本身 - */ - public Maps set(String attr, Object value) { - this.put(attr, value); - return this; - } - - /** - * 设置列,当键或值为null时忽略 - * @param attr 属性 - * @param value 值 - * @return 本身 - */ - public Maps setIgnoreNull(String attr, Object value) { - if(null != attr && null != value) { - set(attr, value); - } - return this; - } - - /** - * 获得特定类型值 - * @param attr 字段名 - * @param defaultValue 默认值 - * @return 字段值 - */ - @SuppressWarnings("unchecked") - public T get(String attr, T defaultValue) { - final Object result = get(attr); - return (T)(result != null ? result : defaultValue); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public String getStr(String attr) { - return Conver.toStr(get(attr), ""); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public Integer getInt(String attr) { - return Conver.toInt(get(attr), 0); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public Long getLong(String attr) { - return Conver.toLong(get(attr), null); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public Float getFloat(String attr) { - return Conver.toFloat(get(attr), null); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public Boolean getBool(String attr) { - return Conver.toBool(get(attr), null); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public byte[] getBytes(String attr) { - return get(attr, null); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public Date getDate(String attr) { - return get(attr, null); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public Time getTime(String attr) { - return get(attr, null); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public Timestamp getTimestamp(String attr) { - return get(attr, null); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public Number getNumber(String attr) { - return get(attr, null); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public BigDecimal getBigDecimal(String attr) { - return get(attr, null); - } - - /** - * @param attr 字段名 - * @return 字段值 - */ - public BigInteger getBigInteger(String attr) { - return get(attr, null); - } - - //-------------------------------------------------------------------- 特定类型值 - - @Override - public Maps clone() { - return (Maps) super.clone(); - } - - //-------------------------------------------------------------------- 特定类型值 -}