Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Problem with struts 2

struts2

2007-03-25

Replies:


Hi everyone,

        I have just started working with struts 2. Quit improved and
much like Spring(except DI and AOP), this is first time i am working with
struts and in HelloWorld programmer i am facing error when my action class
is called and the error is : The requested resource
(/hello_world/example/HelloWorld.action) is not available.

I am putting up my files below, any idea would be appreciated.

web.xml


<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

  <display-name>Struts example by Sachin</display-name>

  <filter>
    <filter-name>struts2</filter-name>
   
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

</web-app>




struts.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
  <package name="example" namespace="/example" extends="struts-default">
    <action name="HelloWorld" class="example.HelloWorld">
       <result>/jsp/HelloWorld.jsp</result>
    </action>
  </package>
</struts>



HelloWorld.java


package example;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {

  public static final String MESSAGE = "Struts is up and running ...";

  public String execute() throws Exception {
    setMessage(MESSAGE);
    return SUCCESS;
  }

  private String message;

  public void setMessage(String message){
    this.message = message;
  }

  public String getMessage() {
    return message;
  }
}


--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.