Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
-none-

-none-

2007-08-15       - By rakeshxp

 Back

I am using Struts 2.0.6 and the jar contains struts struts-default.xml which
contains the following property
<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="struts"
class="org.apache.struts2.dispatcher.mapper.DefaultActionMapper" />
   <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="composite"
class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper" />
   <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="restful"
class="org.apache.struts2.dispatcher.mapper.RestfulActionMapper" />
   <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper"
name="restful2"
class="org.apache.struts2.dispatcher.mapper.Restful2ActionMapper" />
   
We have a struts.xml in WEB-INF/classes folder and I was trying to override
the default actionmapper by having the following lines in my struts.xml (
just for testing I am overriding with the default class itself )
<bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="struts"
class="org.apache.struts2.dispatcher.mapper.DefaultActionMapper" />

But this results in an error when I started up tomcat
Unable to load bean: type:org.apache.struts2.dispatcher.mapper.ActionMapper
class:org.apache.struts2.dispatcher.mapper.DefaultActionMapper - bean -
file:/C:/software/tomcat6/webapps/abc/WEB-INF/classes/struts.xml:17:149

Caused by: Bean type interface
org.apache.struts2.dispatcher.mapper.ActionMapper with the name struts has
already been loaded by [unknown location] - bean -
file:/C:/software/tomcat6/webapps/abc/WEB-INF/classes/struts.xml:17:149

So the question that I have are
1) How do I override the mapping class ?
2) Why are there 4 bean declaration for actionmapper ?

thanks in advance!



JBL wrote:
>
> Final answer: we implemented a custom ActionMapper that handles a URL
> string that doesn't involve a ? to separate the query parameters. Stuck a
> reference to it in struts.properties:
>
> struts.mapper.class=mypackage.MyActionMapper
>
> Building a new ActionMapper isn't terribly difficult. It helps to define
> your expected URLs with a regular expression, then use a precompiled
> pattern. Ours looks something like:
>
> private static String NAMESPACE_REGEX = "...";
> private static String ACTION_REGEX = "...";
> private static String METHOD_REGEX = "...";
> private static String PARAMS_REGEX = "...";
>
> private static String URI_REGEX = (concatenate the four above)
>
> private static Pattern URI_PATTERN = Pattern.compile(URI_REGEX);
>
> Then, in getMapping(), pull out the URI (similar to DefaultActionMapper)
> and call
>
> Matcher m = URI_PATTERN.matcher(uri);
>
> If you get a match, create a new ActionMapping and set its components
> based on the matching groups:
>
> mapping.setNamespace(m.group(1));
> mapping.setName(m.group(1));
>
> etc.
>
> You can parse the parameter section and build a map to pass to
> mapping.setParams().
>
> Using a precompiled pattern may or may not be the most efficient possible
> solution, but it helps you define exactly what URIs you expect. I
> recommend throwing a bunch of possibilities at it in your unit test code
> with various components present and missing. If you're a little unsure
> about regular expressions, build some unit tests for those, too. Sun has a
> decent write-up in their Java documentation:
>
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html
>
> Especially read the "Groups and Capturing" section, it's a handy tool to
> have in your portfolio.
>
> We may yet discover why we couldn't get query parameters, but this works
> for now. Good luck.
>

--
View this message in context: http://www.nabble.com/Struts-2 (See http://uts-2.ora-code.com)-URL-parameters
-lost-tf4196254.html#a12160600
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.