我想通过在 .properties 文件中编写 userEmail、userPassword 和 userRole 来进行注册,然后在 auth-config.xml 中使用它们。所以,我在 loginManagerBean 中做这个:我知道注册方法中的代码重复,我会修复它
public void register(String Remail, String Rpassword, String Rrole) throws InvalidUserException{
Properties prop = new Properties();
InputStream in = getClass().getResourceAsStream("auction-roles.properties");
try {
prop.load(in);
prop.setProperty(Remail,Rrole);
prop.store(new FileOutputStream("auction-roles.properties"), null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Properties prop2 = new Properties();
InputStream in2 = getClass().getResourceAsStream("auction-users.properties");
try {
prop2.load(in2);
prop2.setProperty(Remail,Rpassword);
prop2.store(new FileOutputStream("auction-users.properties"), null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
login(Remail,Rpassword);
}
LoginManager 是一个命名的、会话范围的、有状态的 bean.. 问题是登录是 WORKING,但在注册时:
<h:commandButton id="registerButton" value="register"
action="#{loginManager.register(registerEmail, registerPassword, registerRole)}"/>
单击注册按钮后出现此错误:
javax.servlet.ServletException: javax.el.MethodNotFoundException: /templates/register.xhtml @34,86 action="#{loginManager.register(registerEmail, registerPassword, registerRole)}": Method not found: class org.auction.LoginManager$244422980$Proxy$_$$_Weld$EnterpriseProxy$.register(java.lang.String, java.lang.String, java.lang.String)