Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Estou com dúvida no curso de Struts 1 e a Web, no exercício do capítulo Uma ação Struts - Model View e Controller.

Apareceu o erro dizendo que ; Path ok does not starts with a "/" character

//minha action

package br.com.caelum.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//imports....
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 TesteSimplesAction extends Action {
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        System.out.println("...executando o codigo da logica de negocios...");
        return new ActionForward("ok");
    }
}

//meu struts-config.xml

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
          "http://struts.apache.org/dtds/struts-config_1_3.dtd">

<struts-config>
<action-mappings>
<action path="/teste" type="br.com.caelum.struts.action.TesteSimplesAction">
    <forward name="ok" path="/exemplo.jsp"/>
</action>
</action-mappings>
</struts-config>

//meu web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>struts</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

  <servlet>
      <servlet-name>strutsServlet</servlet-name>
      <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
      <servlet-name>strutsServlet</servlet-name>
      <url-pattern>*.do</url-pattern>
  </servlet-mapping>

</web-app>
1 resposta
solução!

Troquei a linha

return new ActionForward("ok");

//por

return mapping.findForward("ok");

Vlw