| | |
| | | import com.google.gson.JsonSyntaxException; |
| | | import com.whyc.pojo.UserInf; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.web.context.ContextLoader; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | import sun.misc.BASE64Decoder; |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.Optional; |
| | | |
| | | import static jdk.nashorn.internal.objects.NativeNumber.toFixed; |
| | | import java.util.Locale; |
| | | |
| | | public class ActionUtil{ |
| | | |
| | | public static String time_yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss"; |
| | | public static String time_yyyyMMdd = "yyyy-MM-dd"; |
| | | public static SimpleDateFormat sdfwithOutday=new SimpleDateFormat("yyyy_MM"); |
| | | public static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | public static SimpleDateFormat sdfwithOutday = new SimpleDateFormat("yyyy_MM"); |
| | | public static SimpleDateFormat sdfwithday = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | /* |
| | | * 获取HttpServletRequest |
| | |
| | | * @return 返回application |
| | | */ |
| | | public static ServletContext getApplication(){ |
| | | ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext(); |
| | | return servletContext; |
| | | return getSession().getServletContext(); |
| | | } |
| | | //获取application中互斥上传的标志位flag |
| | | public static int getFlag(){ |
| | |
| | | * @return |
| | | */ |
| | | public static boolean generateImage(String imgStr, String path) { |
| | | if (imgStr == null) |
| | | return false; |
| | | if (imgStr == null) { |
| | | return false; |
| | | } |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | | try { |
| | | // 解密 |
| | |
| | | String signNow = (String) EncryptionMD5(usefulNum); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < 10; i++) { |
| | | sb.append(signNow.charAt(i*2)); |
| | | sb.append(signNow.charAt(i * 2)); |
| | | } |
| | | String signResult = sb.append(signNow).toString(); |
| | | return sign.equals(signResult); |
| | | } |
| | | |
| | | //获取当前系统的语言环境 |
| | | public static String getLang() { |
| | | Locale locale = Locale.getDefault();//对Locale类实例化定义 |
| | | String lang = locale.getLanguage(); |
| | | String str = (String) ActionUtil.getSession().getAttribute("lang"); |
| | | if (str != null) { |
| | | lang = str; |
| | | } |
| | | return lang; |
| | | } |
| | | } |