Using the setAllowedFields() method in Spring

后端 未结 4 740
后悔当初
后悔当初 2021-01-15 05:56

I\'m using Spring 3.2.0. I have registered a few custom property editors for some basic needs as follows.

import editors.DateTimeEditor;
import edito         


        
4条回答
  •  Happy的楠姐
    2021-01-15 06:14

    Instead of using setAllowedFields() to white-list, you can use setDisallowedFields() to black-list. For example, from the petclinic sample application:

    @InitBinder
    public void setAllowedFields(WebDataBinder dataBinder) {
        dataBinder.setDisallowedFields("id");
    }
    

    From a pure security standpoint white-listing is preferred to black-listing, but it maybe help ease the burden some.

提交回复
热议问题