|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 | |
|
Senior Member
Iscritto dal: Jan 2002
Città: Napoli
Messaggi: 1727
|
Problema con Struts
Sto cercando di capire Struts e leggevo il tutorial per Netbeans qui:
http://www.netbeans.org/kb/50/quicks...ps-struts.html Son riuscito a far funzionare tutto tranne il pulsante di "Cancel". In struts-config.xml ho: Codice:
<action-mappings>
<action input="/loginForm.jsp" name="NewStrutsActionForm" path="/login" scope="request" type="com.myapp.struts.NewStrutsAction">
<forward name="success" path="/loginSuccessful.jsp"/>
<forward name="cancel" path="/loginCancel.jsp"/>
</action>
<action forward="/loginOut.jsp" path="/logout"/>
<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>
Codice:
public class NewStrutsAction extends Action {
private final static String SUCCESS = "success";
private final static String CANCEL = "cancel";
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (isCancelled(request)) {
return mapping.findForward(CANCEL);
}
return mapping.findForward(SUCCESS);
}
}
Funzionano sia il Submit, il Logout, Il Reset spiegati su quel tutorial, ma il "Cancel" non ne vuole sapere di funzionare. Ecco loginForm.jsp: Codice:
<h1>Login Form</h1>
<html:link action="/logout">Logout</html:link>
<html:form action="login">
<table border="1">
<thead>
<tr>
<th><bean:message key="login.name" /></th>
</tr>
</thead>
<tbody>
<tr>
<td><html:text property="name" /></td>
</tr>
</tbody>
</table>
<html:submit value="Login" />
<html:reset />
<html:cancel />
<html:errors />
</html:form>
Codice:
<h1>Login Form</h1>
<a href="/LoginPage/logout.do">Logout</a>
<form name="NewStrutsActionForm" method="post" action="/LoginPage/login.do">
<table border="1">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" name="name" value=""></td>
</tr>
</tbody>
</table>
<input type="submit" value="Login">
<input type="reset" value="Reset">
<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;">
<span style="color: red">Enter a name!</span>
</form>
Quote:
__________________
Se buttassimo in un cestino tutto ciò che in Italia non funziona cosa rimarrebbe? Il cestino. |
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: Jan 2002
Città: Napoli
Messaggi: 1727
|
Quote:
Grazie! ora funziona
__________________
Se buttassimo in un cestino tutto ciò che in Italia non funziona cosa rimarrebbe? Il cestino. |
|
|
|
|
|
#4 |
|
Junior Member
Iscritto dal: Feb 2008
Città: Pisa
Messaggi: 1
|
Potresti postare come hai risolto il problema? Non riesco a venirne a capo!
Grazie |
|
|
|
|
#5 | |
|
Junior Member
Iscritto dal: Oct 2007
Messaggi: 7
|
Quote:
Pertanto inserisci questo.... <%@ taglib uri="/tags/struts-html" prefix="html" %> dove uri è il percorsoin cui si trova la libreria struts-htlm.tld fammi sapere |
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Thread chiuso
| V |
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 23:57.



















