Hi Phil, i see your point, when action is configured to catch all requests like that it will catch all *.gif requests, maybe add namespace to your action and that will solve your problem, then You will call any action but in /Example/mynamespace/* and You will store your images in /images directory, don't forget to not to use realative address for your image file - do it like this < img src="/images/logo.gif" /> Still, if You want to use one action in struts, it's pointles to use struts - but that's just my point of view.
Best greetings, Paweł Wielgus 2010/6/3 Phil Davis <texasp...@gmail.com>: > Thanks for your response Pawel, > > I am still having problems, so I have included a sample setup. I am using > Eclipse and GlassFish v3. The files in my WAR are: > > /images/logo.gif > /META-INF/MANIFEST.MF > /WEB-INF/classes/com/example/ > actions/MainSite.class > /WEB-INF/classes/struts.xml > /WEB-INF/lib/commons-logging-1.1.jar > /WEB-INF/lib/freemarker-2.3.8.jar > /WEB-INF/lib/ognl-2.6.11.jar > /WEB-INF/lib/struts2-core-2.0.11.jar > /WEB-INF/lib/xwork-2.0.4.jar > /WEB-INF/sun-web.xml > /WEB-INF/web.xml > > the contents of the four important files are: > > 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_2_5.xsd" id="WebApp_ID" > version="2.5"> > <display-name>Example</display-name> > > <filter> > <filter-name>struts2</filter-name> > > <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> > <init-param> > <param-name>actionPackages</param-name> > <param-value>com.example.actions</param-value> > </init-param> > </filter> > > <filter-mapping> > <filter-name>struts2</filter-name> > <url-pattern>/*</url-pattern> > </filter-mapping> > </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> > <constant name="struts.devMode" value="true"/> > <constant name="struts.action.extension" value="action"/> > > <package name="default" extends="struts-default"> > <action name="example" class="com.example.actions.MainSite"> > > <result name="SUCCESS">/MainSite.jsp</result> > </action> > </package> > </struts> > > MainSite.java: > package com.example.actions; > > public class MainSite > { > private String msg; > > public String execute() > { > setMsg( "Fred was here"); > return( "SUCCESS"); > } > > public String getMsg() > { > return msg; > } > > public void setMsg( String msg) > { > this.msg = msg; > } > } > > MainSite.jsp: > <%@ page language="java" contentType="text/html; charset=ISO-8859-1" > pageEncoding="ISO-8859-1"%> > <%@ taglib prefix="s" uri="/struts-tags"%> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " > http://www.w3.org/TR/html4/loose.dtd"> > <html> > <head> > <title>Insert title here</title> > <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> > </head> > <body> > <img src="images/logo.gif"/> > <br/> > The Message is: <s:property value="msg"/> > </body> > </html> > > > and the results are: > > http://localhost:8080/Example/example.action > <<logo>> > The Message is: Fred was here > > http://localhost:8080/Example/example > 404 > > http://localhost:8080/Example > 404 > > http://localhost:8080/Example/images/logo.gif > <<logo>> > > This works as expected! > > So, I change the struts.xml file action name to star: > > <action name="*" class="com.example.actions.MainSite"> > > and ran again, and I get the same results, except I can also go to > asdf.action, foobar.action and get the same results as example.action > > > So, I change action name back to "example" and change extension to "" > > <constant name="struts.action.extension" value=""/> > .... > <action name="example" class="com.example.actions.MainSite"> > > and the results are: > > http://localhost:8080/Example/example.action > Struts Problem Report > Struts has detected an unhandled exception: > Messages: * There is no Action mapped for namespace / and action name > example.action > .... > > http://localhost:8080/Example/example > The Message is: Fred was here > > http://localhost:8080/Example > Struts Problem Report > Struts has detected an unhandled exception: > Messages: * There is no Action mapped for namespace / and action name . > .... > > http://localhost:8080/Example/images/logo.gif > Struts Problem Report > Struts has detected an unhandled exception: > Messages: * There is no Action mapped for namespace / and action name > logo.gif. > .... > > > Please notice that the logo does not show up on Example/example nor in > Example/images/logo.gif > > > and finally, I change both lines in the struts.xml file: > <constant name="struts.action.extension" value=""/> > <action name="*" class="com.example.actions.MainSite"> > > http://localhost:8080/Example/example.action > The Message is: Fred was here > > http://localhost:8080/Example/example > The Message is: Fred was here > > http://localhost:8080/Example > The Message is: Fred was here > > http://localhost:8080/Example/images/logo.gif > The Message is: Fred was here > > > Please notice that the logo does not show up in any page > > > I believe I have done a thorough job in testing this. My conclusion is that > empty extension does not work as required as it blocks all requests for > files. Instead, it calls the action. This is kinda expected, as I am > telling it to process all files by calling the MainSite action. However, I > need it to process regular files, such as the logo.gif and css files, etc. > > > As a side note, I also tested /Example/images and got the unhandled > exception error > > Phil > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org