Question

Yet another question on this I know, but let me just say I looked everything else or about. So, I'm currently building the structure of my Struts 2 Project. I use Struts 2.3.4, JBoss 7.1 and Eclipse Indigo. I also included all the necessary jar into my project. The problem is when I run my application (Add project to Jboss, Run On Server) and go "http://localhost:8080/booxstore/" I get this:

Etat HTTP 404 - There is no Action mapped for namespace [/] and action name [] associated with context path [/booxstore]

Project

My 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" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
id="WebApp_ID" version="3.0">
  <display-name>Booxstore</display-name> 

  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

</web-app>

My 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>
    <constant name="struts.devMode" value="false" />
    <package name="pages" namespace="/pages" extends="struts-default">
        <action name="afficher" class="com.booxstore.controller.DisplayAction" >
            <result name="SUCCESS">/center.jsp</result>
        </action>
    </package>
 </struts>

My action :

/**
 * 
 */
package com.booxstore.controller;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class DisplayAction extends ActionSupport {

    /**
     * 
     */
    private static final long serialVersionUID = 8199854978749642334L;

    public String execute() throws Exception{
        System.out.println("IN");
        return Action.SUCCESS;
    }
}

My JSP just have plain text and have imported struts 2 tags. Basically no matter what I do I can't get a resource. If I go to "http://localhost:8080/booxstore/" or "http://localhost:8080/booxstore/DisplayAction" I get "There is no action mapped" and if I tried to access directly the jsp I get a 404. Please note my war is deployed and enabled on the server.

Was it helpful?

Solution

Put index.jsp under WebContent folder, move pages folder to WEB-INF and then change the struts.xml with:

<struts>
 <constant name="struts.devMode" value="false" />
 <package name="pages" extends="struts-default">
    <action name="afficher" class="com.booxstore.controller.DisplayAction" >
        <result name="SUCCESS">/WEB-INF/pages/center.jsp</result>
    </action>
 </package>
</struts>

I think that the problem is that the application is not finding the jsps that you are putting in the configuration files. And META-INF folder is not the place for putting your jsps pages if you don't want to make them public, WEB-INF is better for that purpose.

OTHER TIPS

To prevent misunderstandings about mappings, add the config browser plugin jar to your application. It will allow you to browse all pages. Caution! Only deploy the dependency in dev or testing, never ond production. Use maven profiles for this restrictions.

http://struts.apache.org/release/2.3.x/docs/config-browser-plugin.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top