- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因为我使用@phone 注释作为 validator ,所以它上升了一些异常作为非法参数。有什么线索吗?如何使用@Ajay 在此 im 中使用我们自己的注释进行电话验证但它不起作用。请帮助我解决此问题并向我发送用于自定义验证的代码。或者请分享一些链接以了解自定义验证。
这是我的模型类:
package com.dineshonjava.bean;
import com.dineshonjava.validator.Ajay;
@Entity
@Table(name="employees")
@SecondaryTable(name="employeedetails")
public class EmployeeBean {
@Ajay
private String phone;
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
这是我自定义的注释类。这段代码是我从互联网上获得的,但在我的项目中实现时显示错误。我不知道如何在我的项目中进行自定义验证。阿杰注解:
package com.dineshonjava.validator;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.RetentionPolicy;
import javax.validation.Constraint;
import javax.validation.Payload;
@Documented
@Constraint(validatedBy = AjayValidator.class)
@Target( { ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Ajay {
String message() default "{Phone}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
这是我的 validator 类,我在这里编写代码来验证我的电话号码,我为 @Ajay 注释做了自定义验证,我在这个 validator 类中进行了验证。Ajay validator :
package com.dineshonjava.validator;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class AjayValidator implements ConstraintValidator<Ajay, String> {
@Override
public void initialize(Ajay ajay) {
}
@Override
public boolean isValid(String phone, ConstraintValidatorContext cxt) {
if(phone == null) {
return false;
}
return phone.matches("[0-9()-/.]*");
}
}
运行我的代码时出错:
Nov 20, 2017 12:37:57 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_151\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_151/bin/server;C:/Program Files/Java/jre1.8.0_151/bin;C:/Program Files/Java/jre1.8.0_151/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ecllipse\eclipse;;.
Nov 20, 2017 12:37:58 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Spring3HibernateApp' did not find a matching property.
Nov 20, 2017 12:37:58 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Nov 20, 2017 12:37:58 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Nov 20, 2017 12:37:58 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 438 ms
Nov 20, 2017 12:37:58 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 20, 2017 12:37:58 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
log4j:WARN No appenders could be found for logger (org.springframework.web.servlet.DispatcherServlet).
log4j:WARN Please initialize the log4j system properly.
Nov 20, 2017 12:38:00 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'sdnext'
Nov 20, 2017 12:38:02 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Nov 20, 2017 12:38:02 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Nov 20, 2017 12:38:02 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3897 ms
Nov 20, 2017 12:38:04 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NumberFormatException: For input string: "Phone"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.text.MessageFormat.makeFormat(Unknown Source)
at java.text.MessageFormat.applyPattern(Unknown Source)
at java.text.MessageFormat.<init>(Unknown Source)
at org.springframework.context.support.MessageSourceSupport.createMessageFormat(MessageSourceSupport.java:115)
at org.springframework.context.support.MessageSourceSupport.formatMessage(MessageSourceSupport.java:99)
at org.springframework.context.support.AbstractMessageSource.renderDefaultMessage(AbstractMessageSource.java:275)
at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:152)
at org.springframework.context.support.AbstractApplicationContext.getMessage(AbstractApplicationContext.java:1165)
at org.springframework.web.servlet.support.RequestContext.getMessage(RequestContext.java:559)
at org.springframework.web.servlet.support.BindStatus.initErrorMessages(BindStatus.java:177)
at org.springframework.web.servlet.support.BindStatus.getErrorMessages(BindStatus.java:273)
at org.springframework.web.servlet.tags.form.ErrorsTag.exposeAttributes(ErrorsTag.java:172)
at org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag.writeTagContent(AbstractHtmlElementBodyTag.java:48)
at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
at org.apache.jsp.WEB_002dINF.views.addEmployee_jsp._jspService(addEmployee_jsp.java:393)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Nov 20, 2017 12:38:04 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [sdnext] in context with path [/sdnext] threw exception [java.lang.IllegalArgumentException: can't parse argument number: Phone] with root cause
java.lang.NumberFormatException: For input string: "Phone"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.text.MessageFormat.makeFormat(Unknown Source)
at java.text.MessageFormat.applyPattern(Unknown Source)
at java.text.MessageFormat.<init>(Unknown Source)
at org.springframework.context.support.MessageSourceSupport.createMessageFormat(MessageSourceSupport.java:115)
at org.springframework.context.support.MessageSourceSupport.formatMessage(MessageSourceSupport.java:99)
at org.springframework.context.support.AbstractMessageSource.renderDefaultMessage(AbstractMessageSource.java:275)
at org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:152)
at org.springframework.context.support.AbstractApplicationContext.getMessage(AbstractApplicationContext.java:1165)
at org.springframework.web.servlet.support.RequestContext.getMessage(RequestContext.java:559)
at org.springframework.web.servlet.support.BindStatus.initErrorMessages(BindStatus.java:177)
at org.springframework.web.servlet.support.BindStatus.getErrorMessages(BindStatus.java:273)
at org.springframework.web.servlet.tags.form.ErrorsTag.exposeAttributes(ErrorsTag.java:172)
at org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag.writeTagContent(AbstractHtmlElementBodyTag.java:48)
at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
at org.apache.jsp.WEB_002dINF.views.addEmployee_jsp._jspService(addEmployee_jsp.java:393)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
最佳答案
您的问题的解决方案就在您的问题中:
java.lang.NumberFormatException: For input string: "Phone"
您尝试将字符串“Phone”解析为数字。当然,这是不可能的,因为它不包含任何数字,而只包含字符。
关于java.lang.IllegalArgumentException : can't parse argument number: Phone 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47387176/
我发现在使用parse-node包时,不能再使用Parse.Cloud.httpRequest了。我也知道 Parse 的 Image 对象将不可用。 到目前为止,我已经能够用原生的替换一些 Pars
关闭。这个问题是opinion-based 。目前不接受答案。 已关闭 9 年前。 已锁定。这个问题及其答案是locked因为这个问题是题外话,但却具有历史意义。目前不接受新的答案或互动。 我有一个函
开源 Parse Server 是否包含用于配置新 Parse 实例的 Schema API?我试图消除手动创建应用程序的需要。 这是通过 Parse.com 提供的架构 API http://blo
我想从我的云代码发出一个 http 请求,该请求在我的客户端被调用。 最佳答案 一开始我发现这有点令人困惑,所以希望这会有所帮助。 在您的云代码中main.js Parse.Cloud.define(
这部分代码应该读入两个或更多数字(省略主 io 函数),然后是一个“+”来给出总和。使用有理数是因为稍后我将进行乘法和其他此类操作。 data Expression = Number Rationa
我似乎找不到任何关于此的官方信息:Does Parse.Config work on Parse Server?它曾经在 Parse.com 上工作,但是当我尝试迁移到 Parse.Server 时,
我正在尝试找到使用 Parse.com 添加密码要求的最佳程序。似乎最简单的方法是在保存用户数据之前使用云功能执行。我唯一的警告是,只有当密码与数据库中存储的密码不同或者用户不存在于数据库中时,我才想
我是 android 开发、应用程序开发和一般开发的初学者,我正在尝试为我的 android 应用程序设置后端数据库。我决定使用一个名为 back4app 的服务,以便获得更加用户友好的数据库体验,因
我目前正在尝试将 Facebook 登录功能添加到我的应用程序。 根据Android文档,当我添加 compile 'com.parse:parsefacebookutils-v4-android:1
我正在尝试使用 Rebol 2/3 从字符串中解析货币值,货币值的格式为: 10,50 欧元或 10,50 欧元 我在浏览了所有 PARSE 文档后想出了这段代码,我可以在 Red 中找到它,但在 R
代码: DateTimeFormat dateFormat = DateTimeFormat .getFormat("EEE MMM dd HH:mm:ss zzz y
我不再在 Parse 上看到用于导入 JSON 或 CSV 文件的导入按钮。他们是否将其移动到某个地方,或者不再可能导入这些文件类型? 最佳答案 官方原因是这样的: “[导入类按钮] 几天前被删除,因
我正在使用 PHP 从我的服务器检索一些数据。我想在 javascript 应用程序中使用这些数据,所以我正在做这样的事情: var polylines = ; $polylines 只是一个 PHP
我已经开始使用 .NET 4 System.Numerics.BigInteger Structure我遇到了一个问题。 我正在尝试解析一个包含无符号(正数)的十六进制数字的字符串。我得到一个负数。
我正在使用 PHP 从我的服务器检索一些数据。我想在 javascript 应用程序中使用这些数据,所以我正在做这样的事情: var polylines = ; $polylines 只是一个 PHP
在 Go 中,尝试将字符串转换为 time.Time 时,使用时间包的 Parse 方法不会返回预期结果。似乎问题出在时区。我想更改为 ISO 8601 结合 UTC 日期和时间。 package m
我正在尝试将此字符串模式 "4-JAN-12 9:30:14" 解析为 time.Time。 尝试了 time.Parse("2-JAN-06 15:04:05", inputString) 和许多其
从云代码和解析开始。使用this . 如何删除所有 Parse 项目以便开始创建新项目?我收到以下错误: “您想要创建一个新应用程序,还是将 Cloud Code 添加到现有应用程序中?输入“(n)e
我在解析云代码时有这个功能: Parse.Cloud.define("testfunction", function(request, response) { var username = r
最近,我在 parse.com 上做了一些测试。我现在面临在后台作业中使用 Parse.Object.saveAll 的问题。 从 parse.com 的文档来看,后台作业可以运行 15 分钟。我现在
我是一名优秀的程序员,十分优秀!