Not sure where to submit an bug report, since the JIRA link seems to be
broken... So, I am posting it here.
Blank Extensions break the normal processing of non-action files.
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-nameWebSite/display-name
filter
filter-namestruts2/filter-name
filter-classorg.apache.struts2.dispatcher.FilterDispatcher/filter-class
init-param
param-nameactionPackages/param-name
param-valuecom.example.actions/param-value
/init-param
/filter
filter-mapping
filter-namestruts2/filter-name
url-pattern/*/url-pattern
/filter-mapping
welcome-file-list
welcome-fileindex.jsp/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
constant name=struts.devMode value=true/
constant name=struts.action.extension value=/
package name=default extends=struts-default
action name=home
result/home.jsp/result
/action
/package
/struts
In addition to these two xml files, I have two image files and two jsp
files:
/logo.gif
/images/logo.gif
/index.jsp
/home.jsp
The image files are unique so I know which is being displayed. The JSP
files are unique so I know which is being displayed. (ie this is home and
this is index)
Results:
-
I have gone to each of the specified URLs, with the following results:
/home
This works as expected. I see a page that says this is home
/home.jsp
Error page with the message: There is no Action mapped for namespace / and
action name home.jsp
/index.jsp
Error page with the message: There is no Action mapped for namespace / and
action name index.jsp
/
Error page with the message: There is no Action mapped for namespace / and
action name index.jsp
/logo.gif
Error page with the message: There is no Action mapped for namespace / and
action name logo.gif
/images/logo.gif
Error page with the message: There is no Action mapped for action name
logo.gif
I believe this is not the intended result. I would expect the same results
that I get if I set the extension to action (with the corresponding URLs)
These results are as follows:
/home.action
This works as expected. I see a page that says this is home
/home
Error 404 (expected result)
/home.jsp
I see a page that says this is home, but it is not the result of the
action (parameters in the action are not processed)
/index.jsp
This works as expected. I see a page that says this is index
/
This works as expected. I see a page that says this is index
/logo.gif
Works as expected, I see the logo image.
/images/logo.gif
Works as expected, I see the other logo image.
I consider this a bug, since the behavior is quite different between the two
scenarios. Restating it again, I expect the same behavior when the
extension is blank as when it is action or do or fred, except there is
no extension. I also expect non-actions to be processed as normal.
Expected solution:
When an extension is specified, the actual action name is the concatenation
of the specified action name plus the extension. For example:
home.action. Requests that don't match the actual action name, are
considered normal file requests.
When a blank extension is specified, the actual action name is exactly what
is specified in the action name, without the addition of the extension. For
example: home. But other requests that don't match specified action names
would be considered normal file requests. (BTW, with blank extensions the
action name may specify an extension, for example home.do)
Phil