我正在尝试使用http://code.google.com/p/kaptcha/这看起来是一种包含 CAPTCHA 的非常简单的方法。我的演示应用程序是 JSF,虽然JSP的说明很简单,但我不知道如何在 JSF 中使用它们。我如何在 JSF 中翻译这个?
在管理提交操作的代码中:
String kaptchaExpected = (String)request.getSession() .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY); String kaptchaReceived = request.getParameter("kaptcha");
if (kaptchaReceived == null || !kaptchaReceived.equalsIgnoreCase(kaptchaExpected)) { setError("kaptcha", "Invalid validation code."); }
我试着把它放在我的:
public String button1_action() {
// TODO: Process the action.
return "success";
}
但它不理解请求对象:(