validator用法注释
This commit is contained in:
parent
6d44e18795
commit
85b0b27938
@ -29,7 +29,7 @@ public class ActivityFormConfigure {
|
|||||||
add("assist-manager");
|
add("assist-manager");
|
||||||
add("attendance");
|
add("attendance");
|
||||||
}};
|
}};
|
||||||
public final static HashMap<String, Set<String>> stdActivityMap;
|
public final static Map<String, HashSet<String>> stdActivityMap;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
stdActivityMap = new HashMap() {{
|
stdActivityMap = new HashMap() {{
|
||||||
|
@ -2,11 +2,9 @@ package com.codesdream.ase.controller;
|
|||||||
|
|
||||||
import com.codesdream.ase.component.ASESpringUtil;
|
import com.codesdream.ase.component.ASESpringUtil;
|
||||||
import com.codesdream.ase.configure.ActivityFormConfigure;
|
import com.codesdream.ase.configure.ActivityFormConfigure;
|
||||||
import com.codesdream.ase.configure.AppConfigure;
|
|
||||||
import com.codesdream.ase.exception.InvalidFormFormatException;
|
import com.codesdream.ase.exception.InvalidFormFormatException;
|
||||||
import com.codesdream.ase.service.ActivityService;
|
import com.codesdream.ase.service.ActivityService;
|
||||||
import com.codesdream.ase.validator.WebFormValidator;
|
import com.codesdream.ase.validator.WebFormValidator;
|
||||||
import org.springframework.http.HttpRequest;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -23,10 +21,10 @@ public class ActivityController {
|
|||||||
@Resource
|
@Resource
|
||||||
ActivityService activityService;
|
ActivityService activityService;
|
||||||
|
|
||||||
@RequestMapping(value = "/activityCreator")
|
@RequestMapping(value = "/activity_creator")
|
||||||
String activityCreatorView(Model model){return "activityCreator";}
|
String activityCreatorView(Model model){return "activity_creator";}
|
||||||
|
|
||||||
@PostMapping(value = "/activityCreator")
|
@PostMapping(value = "/activity_creator")
|
||||||
String activityCreator(Model model, HttpServletRequest request) throws InvalidFormFormatException {
|
String activityCreator(Model model, HttpServletRequest request) throws InvalidFormFormatException {
|
||||||
|
|
||||||
Map<String, String[]> parameterMap = request.getParameterMap();
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
||||||
|
@ -2,6 +2,7 @@ package com.codesdream.ase.model.activity;
|
|||||||
|
|
||||||
import com.codesdream.ase.model.permission.User;
|
import com.codesdream.ase.model.permission.User;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import org.springframework.security.core.parameters.P;
|
import org.springframework.security.core.parameters.P;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
@ -4,10 +4,18 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
//用于检查网页表单格式是否合法
|
||||||
@Component
|
@Component
|
||||||
public class WebFormValidator {
|
public class WebFormValidator {
|
||||||
|
|
||||||
public HashMap<String, Boolean> check(Map<String, Set<String>> stdFormMap, Map<String, String[]> webFormMap){
|
/**
|
||||||
|
* 传入标准表单所具有的属性set以及网页表单的属性set,确保map中的key和value一一对应
|
||||||
|
* 检查的时候会将标准表单和网页表单两个map中key相同的value进行完全匹配比较
|
||||||
|
* 返回一个map,不同表单有不同的合法情况
|
||||||
|
* 支持一次处理多个表单,请务必保持对应表单的标准和网页map中的key一样
|
||||||
|
* @return 封装在一个map里的不同表单对应的合法情况
|
||||||
|
*/
|
||||||
|
public HashMap<String, Boolean> check(Map<String, HashSet<String>> stdFormMap, Map<String, String[]> webFormMap){
|
||||||
|
|
||||||
HashMap<String, Boolean> result = new HashMap<String, Boolean>();
|
HashMap<String, Boolean> result = new HashMap<String, Boolean>();
|
||||||
Set<String> stdKey = stdFormMap.keySet();
|
Set<String> stdKey = stdFormMap.keySet();
|
||||||
|
Loading…
Reference in New Issue
Block a user