gpt4 book ai didi

java - JCaptcha4Struts2 插件,图像未加载

转载 作者:行者123 更新时间:2023-11-29 08:50:39 25 4
gpt4 key购买 nike

我是 struts 的新手,我正在开发一个使用验证码验证的应用程序。在研究了预构建的验证码插件之后,我决定使用 JCaptcha4Struts2

很快我就遇到了一系列的麻烦。我解决了所有问题,但我无法解决这个问题。

我按照演示应用程序中给出的所有内容进行了操作,但在我的应用程序中,图像显示不正确。事实上,只出现了一个黑色矩形。这些是我正在使用的库集:

  • commons-collection-3.1
  • commons-io-2.2
  • commons-lang3-3.1
  • commons-logging-1.1.3
  • commons-logging-api-1.1
  • freemarker-2.3.19
  • ognl-3.0.6
  • struts2-core-2.3.16.1
  • xwork-core-2.3.16.1
  • javax.mail-1.5.1 odbc7
  • javassist-3.11.10.GA
  • commons-fileupload-1.3.1
  • jcaptcha4struts2-2.0.2
  • struts2-jquery-plugin-3.7.0
  • jcaptcha-1.0
  • jcaptcha-api-1.0
  • imaging-01012005
  • antlr-2.7.2

我使用的开发环境是:netbeans 8.0,jdk 1.8,java ee 7

请帮助或建议一些其他的 struts2 验证码选项(考虑到我对 struts 很陌生并且项目截止日期不是很远)。

编辑:我读到 struts 2.3.16 在成像方面存在一些问题,所以我也尝试过 struts 2.0.11 库

JSP 文件

<%@taglib prefix="jcaptcha"  uri="http://code.google.com/p/jcaptcha4struts2/taglib/2.0" %>
//some html code
<s:form name="login" action="login" method="post">
<s:textfield name="username" label="Username" size="20" autofocus="true" />
<s:password name="password" label="Password" size="20" />
<jcaptcha:image label="Enter the text" height="30" width="100"/>
<s:submit name="submit" label="Submit" align="center" />
</s:form>

struts.xml

<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.action.extension" value="," />

<package name="default" extends="jcaptcha4struts2-default">
<action name="login"
class="UserLoginAction"
method="execute">
<interceptor-ref name="jcaptchaDefaultStack"/>
<result name="success">/profile.jsp</result>
<result name="input">/</result>
<result name="login">index.jsp</result>
<result name="error">/</result>
</action>

</package>

</struts>

编辑 2:我进一步尝试使用库的各种排列 se 版本(其中大多数是最新的,现在我遇到了异常。这是堆栈跟踪

2014-04-07 16:15:25,874 DEBUG org.apache.struts2.dispatcher.Dispatcher.debug:80 - Exception occurred during processing request: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1575)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1533)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoSuchMethodError: com.jhlabs.image.WaterFilter.setAmplitude(D)V
at com.octo.captcha.engine.image.gimpy.DefaultGimpyEngine.buildInitialFactories(DefaultGimpyEngine.java:59)
at com.octo.captcha.engine.image.ListImageCaptchaEngine.<init>(ListImageCaptchaEngine.java:24)
at com.octo.captcha.engine.image.gimpy.DefaultGimpyEngine.<init>(DefaultGimpyEngine.java:48)
at com.octo.captcha.service.image.DefaultManageableImageCaptchaService.<init>(DefaultManageableImageCaptchaService.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:433)
at com.google.code.jcaptcha4struts2.core.beans.JC4S2Config.getDefaultImageCaptchaService(JC4S2Config.java:110)
at com.google.code.jcaptcha4struts2.core.beans.JC4S2Config.getImageCaptchaService(JC4S2Config.java:82)
at com.google.code.jcaptcha4struts2.core.actions.JCaptchaImageAction.getImageCaptchaService(JCaptchaImageAction.java:107)
at com.google.code.jcaptcha4struts2.core.actions.JCaptchaImageAction.execute(JCaptchaImageAction.java:75)
... 73 more

最佳答案

这个 JCaptcha 库真的很旧,从他们的代码存储库的状态来看,它是一个废弃的项目。这个库的问题是它使用了非常特殊的版本 JH Labs Image filters验证码图片失真,此版本不支持JDK 1.8,只支持1.6。

但如果您使用了 reCAPTCHA,它就不会再困扰您了。刚刚决定分享我的发现。

关于java - JCaptcha4Struts2 插件,图像未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22894510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com