struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morten Solberg <mor...@uniweb.no>
Subject Struts2 Sitemesh handling 404
Date Tue, 04 Aug 2009 08:19:36 GMT
Hi,

I am having a hard time figuring out how to get this working properly. I 
have handled 404 pages / unknown actions this way:

web.xml
<error-page>
	<error-code>404</error-code>
         <location>/error/pagenotfound</location>
</error-page>

struts.xml
<package name="error" namespace="/error" extends="controlpanel-default">
   <action name="pagenotfound" class="com.uniweb.cp.common.Error">
    <result name="success" type="freemarker">/error/notfound.ftl</result>
   </action>
</package>

This works fine and are not decorated. This is what I want. For unknown 
actions e.g URL's like http://localhost:8080/asdf, I have implemented 
UnknownHandler with the definition of handleUnknownAction like this:

public ActionConfig handleUnknownAction(String namespace, String actionName)
             throws XWorkException {
ActionConfig actionConfig = new ActionConfig.Builder("error", 
"pagenotfound", "com.uniweb.cp.common.Error")
				.addResultConfig(new ResultConfig.Builder(Action.SUCCESS, 
resultsByExtension.get("ftl").getClassName())
						.addParams(resultsByExtension.get("ftl").getParams())
						.addParam(resultsByExtension.get("ftl").getDefaultResultParam(), 
"/error/notfound.ftl")
						.build())
				.build();
  return actionConfig;
}

This redirects to the same action, however, notfound.ftl in this case is 
decorated.

Have any of you had the same problem? Or is there another way to solve 
the unknown action problem?


Regards,

Morten Solberg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message