切面中JoinPoint.getArgs()获取到请求参数,转换String 存库

/**
 * 参数拼装
 */
private String argsArrayToString(Object[] paramsArray)
{
    String params = "";
    if (paramsArray != null && paramsArray.length > 0)
    {
        for (Object o : paramsArray)
        {
            if (null!=o && !isFilterObject(o))
            {
                try
                {
                    Object jsonObj = JSON.toJSON(o);
                    params += jsonObj.toString() + " ";
                }
                catch (Exception e)
                {
                }
            }
        }
    }
    return params.trim();
}

@SuppressWarnings("rawtypes")
public boolean isFilterObject(final Object o)
{
    Class clazz = o.getClass();
    if (clazz.isArray())
    {
        return clazz.getComponentType().isAssignableFrom(MultipartFile.class);
    }
    else if (Collection.class.isAssignableFrom(clazz))
    {
        Collection collection = (Collection) o;
        for (Object value : collection)
        {
            return value instanceof MultipartFile;
        }
    }
    else if (Map.class.isAssignableFrom(clazz))
    {
        Map map = (Map) o;
        for (Object value : map.entrySet())
        {
            Map.Entry entry = (Map.Entry) value;
            return entry.getValue() instanceof MultipartFile;
        }
    }
    return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse
            || o instanceof BindingResult;
}

你可能感兴趣的:(springboot,经验,javaweb,servlet,java,开发语言)