Boa tarde Pessoal!
Venho quebrando a cabeça a alguns dias e tenho achado muito dificil “manusear” ambas ferramentas em conjunto.
Quero fazer um esqueminha simples, onde eu entro com nome, sobrenome e id. Faço uma verificacao de nao deixar os campos nome e sobrenome nulos.
Até ai tudo bem.
O que tenho é isso :
Struts-Config
[code]<?xml version="1.0" encoding="UTF-8" ?>
</form-beans>
<global-exceptions>
</global-exceptions>
<global-forwards>
<forward name="welcome" path="/Welcome.do"/>
<forward name="userLogin" path="/userLogin.do"/>
</global-forwards>
<action-mappings>
<action input="/userLogin.vm" name="form" path="/userLogin" type="PersonalAction">
<forward name="success" path="/success.vm" />
<forward name="failure" path="/failure.vm" />
</action>
<action path="/Welcome" forward="/welcomeStruts.vm"/>
<action type="org.apache.struts.actions.ForwardAction" path="/userLogin" parameter="/userLogin.vm"/>
<action type="org.apache.struts.actions.ForwardAction" path="/failure" parameter="/failure.vm"/>
<action type="org.apache.struts.actions.ForwardAction" path="/success" parameter="/success.vm"/>
</action-mappings>
[/code]
[code]
action org.apache.struts.action.ActionServlet application ApplicationResources config /WEB-INF/struts-config.xml debug 2 detail 2 validate true 2 velocity org.apache.velocity.tools.view.servlet.VelocityViewServlet<init-param>
<param-name>org.apache.velocity.toolbox</param-name>
<param-value>/WEB-INF/toolbox.xml</param-value>
<init-param>
<param-name>org.apache.velocity.properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
10
PersonalForm
public class PersonalForm {
private String nome;
private String sobrenome;
private String id;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getSobrenome() {
return sobrenome;
}
public void setSobrenome(String sobrenome) {
this.sobrenome = sobrenome;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
PersonalAction
[code]import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class PersonalAction extends Action {
public ActionForward executes(ActionMapping mapping, ActionForm form,
HttpServletRequest req, HttpServletResponse res) {
PersonalForm psf = (PersonalForm) form; // Acredito que tenha algum enrrosco por aqui
String id = psf.getId();
String nome = psf.getNome();
String sobrenome = psf.getSobrenome();
if ((nome != null) && (sobrenome != null)) {
return mapping.findForward("sucess.vm");
} else
return mapping.findForward("failure.vm");
}
}
[/code]
[code]
<input type=“text” name=“nome"value=”$!personalForm.nome "style=“width: 100%”>
<tr>
<td width="108">Sobrenome</td>
<td width="250">
<input type="text" name="sobrenome" value="$!personalForm.sobrenome"style="width: 100%">
</td>
</tr>
<tr></tr>
<tr>
<td width="108">ID</td>
<td width="250">
<input type="text" name="id" value="$!personalForm.id"style="width: 100%">
</td>
</tr>
<tr></tr>
<td width="382" align="right">
<input type="submit" value="Salvar">
</td>
[/code]
O que está acontecendo :
Após preencher o form, quando sou redirecionado para a login.do, recebo o seguinte erro
[code]type Status report
message /userLogin.do
description The requested resource (/userLogin.do) is not available.[/code]
O que fazer?