我真的是新的Java ....我在使用工具Tapestry框架在java中進行一些研究... 當我調用@Component「Form」時,異常中有一些問題... tapestry拋出異常:跨格式驗證問題掛毯
嵌入式組件loginForm在組件類com.fit.pages.Login(或Login類的超類)中定義,但不存在於組件模板中(classpath:com/FIT /頁/ Login.tml)。
上下文 EVENTTYPE
激活
org.apache.tapestry5.ioc.internal.OperationException
嵌入式成分(S)被登錄表單組件類com.fit.pages中定義的。登錄(或超級的登錄),但不在組件模板(classpath:com/fit/pages/Login.tml)中。
跟蹤
**Triggering event 'activate' on Index
Constructing instance of page class com.fit.pages.Login
Creating ComponentAssembler for com.fit.pages.Login**
我的代碼看起來是這樣的
公共類登錄{
private String userName;
@Property
private String password;
@Inject
@Property
private Users users;
@SessionState
private User user;
@Component(id="loginForm")
private Form loginForm;
@Inject
private Messages messages;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
void onValidate(){
User authenticatedUser = Security.authenticate(userName, password, users);
if(authenticatedUser != null){
user = authenticatedUser;
}else{
loginForm.recordError(messages.get("authentication-failed"));
}
}
@OnEvent
Object onSubmit(){
System.out.println("form was submited");
Class nextPage = null;
User authenticatedUser = Security.authenticate(userName, password, users);
if(authenticatedUser != null){
user = authenticatedUser;
nextPage = Index.class;
} else {
nextPage = Registration.class;
}
return nextPage;
}
和代碼login.tml:
請登錄:
<t:form id="loginForm">
<table>
<tr>
<td>
<t:label t:for="userName"/>:
</td>
<td>
<input type="text" t:type="textfield" t:id="userName"
t:value="userName" t:validate="required"/>
</td>
</tr>
<tr>
<td>
<t:label t:for="password"/>:
</td>
<td>
<input type="text" t:type="passwordfield" t:id="password"
t:value="password" t:validate="required"/>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Log In"/>
</td>
</tr>
</table>
</t:form>
是否使用'進口org.apache.tapestry.form.Form'更換? – sfrj 2011-05-18 11:17:33
您是否試過'' –
sfrj
2011-05-18 11:21:09
我可以問一下您使用Security.authenticate(...)導入了什麼? – 2015-04-05 14:44:53