功能:java实现滑动验证码
项目是采用springboot,maven
开发工具:采用idea
1.效果演示:
2.后端代码:
控制层:
@Controller
public class SliderCodeController {
@Autowired
ResourceLoader resourceLoader;
@Autowired
private FileUtil fileUtil;
// 设置横轴位置缓存
public static Cache< String, Integer > cacheg = CacheBuilder.newBuilder().expireAfterWrite(60, TimeUnit.SECONDS)
.maximumSize(666666).build();
@GetMapping
@RequestMapping("index")
public String test(HttpServletRequest request, Model model) throws IOException {
return "index";
}
@GetMapping
@RequestMapping("getImg")
public @ResponseBody
Map< String, Object > getPic(HttpServletRequest request) throws IOException {
try {
File targetFile = fileUtil.getFile("target");
File tempImgFile = fileUtil.getFile("temp");
Map < String, Object > resu