草庐IT

beans-validation

全部标签

php - MVC : Does the Model or Controller validate user input

用户输入在MVC的哪个部分得到验证?例如,用户注册系统,用户在View中输入数据,用户的输入在哪里被清理和验证是否正确输入,例如。正确的电子邮件,应用php清理功能..这会发生在Controller还是模型中?哪些将决定返回哪些错误谢谢 最佳答案 根据经典的MVC模型(图形应用程序),用户输入也是一个模型。大多数PHP框架都遵循Passive-MVC或MVC-2模型,其中它是Controller或Controller助手的领域。做看起来最易于维护的事情。 关于php-MVC:Doesth

Spring 中 @Bean 注解用法大全,建议收藏!

存储Bean对象将对象存储在Spring中,有两种注解类型可以实现:类注解:@Controller、@Service、@Repository、@Component、@Configuration方法注解:@Bean@Controller(控制器存储)SpringBoot基础就不介绍了,推荐看这个实战项目:https://github.com/javastacks/spring-boot-best-practice如下使用@Controller存储Bean代码:@ControllerpublicclassUserController{publicvoidSayHi(Stringname){Syst

php - 法尔康 3 : Validating form data using\Phalcon\Mvc\Model\Validator

由于发布了最新版本的Phalcon,文档中提供的示例似乎无法正常工作。首先,我用DevTools创建了一个新模型在命令行使用phalconmodelUser。然后,我修改validation()函数。我的models\User.php文件:usePhalcon\Mvc\Model\Validator\EmailasEmail;usePhalcon\Mvc\Model\Validator\UniquenessasUniqueness;usePhalcon\Mvc\Model\Validator\StringLengthasStringLength;classUserextends\Pha

php - Yii2 : Either one field is required Validation

我必须执行标题中提到的验证,即需要两个字段(电子邮件、电话)之一。我在我的model中这样做:[['email'],'either',['other'=>['phone']]],这是方法:publicfunctioneither($attribute_name,$params){$field1=$this->getAttributeLabel($attribute_name);$field2=$this->getAttributeLabel($params['other']);if(empty($this->$attribute_name)&&empty($this->$params[

php - cURL 下载 Zip 文件 - "argument is not a valid File-Handle resource"

我正在尝试使用PHP和cURL从我托管的服务器下载一个zip文件并将其存储在另一台服务器上。我的PHP看起来像这样:set_time_limit(0);$ci=curl_init();curl_setopt_array($ci,array(CURLOPT_FILE=>'/directory/images.zip',//FileDestinationCURLOPT_TIMEOUT=>3600,//TimeoutCURLOPT_URL=>'http://example.com/images/images.zip'//FileLocation));curl_exec($ci);curl_cl

Spring注入bean的常用的六种方式

一.通过注解注入的一般形式Bean类publicclassTestBean{}Configuration类@Configuration注解去标记了该类,这样标明该类是一个Spring的一个配置类,在加载配置的时候会去加载他。@Bean的注解,标明这是一个注入Bean的方法,会将下面的返回的Bean注入IOC。//创建一个class配置文件@ConfigurationpublicclassTestConfiguration{//将一个Bean交由Spring进行管理@BeanpublicTestBeanmyBean(){returnnewTestBean();}}测试类ApplicationCo

php - 拉维尔 5.1/AngularJS : Reset password in Angular view (how to validate CSRF token? )

我设法调整了默认的Laravel身份验证,以便它可以作为我的AngularJS的API,到目前为止一切正常。可以转到/reset并输入一封电子邮件,然后收到一封带有密码重置链接的电子邮件,该链接转到/reset/{token}如果您没有收到任何验证错误,您的密码将成功更改。唯一的问题是,因为我使用的是AngularView,所以在显示reset-password状态之前,实际上没有任何东西可以验证token并确保它不是乱码。我尝试将其添加到Controller的顶部:if($stateParams.token!=$cookies.get('XSRF_TOKEN')){$state.go

php - Composer .json 错误 : "./composer.json" does not contain valid JSON

关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭2年前。Improvethisquestion我制作了一个composer.json脚本。当我运行sudocomposerinstall时,出现此错误:[Seld\JsonLint\ParsingException]"./composer.json"doesnotcontainvalidJSONParseerroronline1:"repositories":[{"t--------------^Expectedoneof:'EOF','}'

php filter_var 在 FILTER_VALIDATE_INT 上失败并返回零

我对以下抛出异常感到困惑:if(!filter_var(0,FILTER_VALIDATE_INT))thrownewException("Nonnumericfieldpassed".$field."whenexpectinganumber:".$variable."passedinstead");任何积极的事情都可以吗?我试过intval(0)但仍然一无所获。零不是整数吗? 最佳答案 人们应该测试false:if(filter_var($value,FILTER_VALIDATE_INT)===false){//$valueis

Bean named ‘redisTemplate‘ is expected to be of type ‘org.springframework.data.redis.core.StringRedi

本文将讲解:该错误的解决办法@Resource和@Autowired两个注解的区别@Autowired这个注解注入的字段爆红今天在引入redis作为缓存中间件的时候,出现了这个错误,org.springframework.beans.factory.UnsatisfiedDependencyException,其实就是我们自动注入的时候报的错误,使用@Resouce这个注解,因为这个注解我们是先通过名字去匹配的,然后再通过type去匹配的报错详细信息:Beannamed'redisTemplate'isexpectedtobeoftype'org.springframework.data.re