java - struts2 action "*_*" works just like "*" -
there 2 actions.and *_*
in front end of **
(it doesn't matter @ default namespace work after specific namespace(unless specific namespace extends it))
<package name="default" namespace="" extends="struts-default"></package> <package name="admin" namespace="/admin" extends="default"> <global-results> <result>/admin/result.jsp</result> </global-results> <action name="login" class="org.cc.action.adminaction"> <result>/admin/admin.jsp</result> </action> <action name="*_*" class=org.cc.action.{1}action" method="{2}"> </action> </package> <package name="error" namespace="" extends="default"> <action name="**" > <result>/error.jsp</result> </action> </package>
there error page defined catching action doesn't exist
then tested action
localhost:8080/myprojectname/admin/adminaction.action(it doesn't exist)
but caught action named "*_*"
because exception showed adminactionaction.class
not found.
then used *__*
(there 2 '_'
). worked , showed error.jsp
.
the format "*a*"
or "*#*"
didn't work either grab action if there no , # in name of action.
the struts version utilize struts 2.3.4.
is there document said between *
, *
there must @ to the lowest degree 2 characters or *
?
and here detail of exception
unable instantiate action, org.cc.action.adminactionaction, defined 'adminaction' in namespace '/admin'org.cc.action.adminactionaction com.opensymphony.xwork2.defaultactioninvocation.createaction(defaultactioninvocation.java:319) com.opensymphony.xwork2.defaultactioninvocation.init(defaultactioninvocation.java:400) com.opensymphony.xwork2.defaultactionproxy.prepare(defaultactionproxy.java:194) org.apache.struts2.impl.strutsactionproxy.prepare(strutsactionproxy.java:63) org.apache.struts2.impl.strutsactionproxyfactory.createactionproxy(strutsactionproxyfactory.java:39) com.opensymphony.xwork2.defaultactionproxyfactory.createactionproxy(defaultactionproxyfactory.java:58) org.apache.struts2.dispatcher.dispatcher.serviceaction(dispatcher.java:501) org.apache.struts2.dispatcher.ng.executeoperations.executeaction(executeoperations.java:77) org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter.dofilter(strutsprepareandexecutefilter.java:91) java.lang.classnotfoundexception: org.cc.action.adminactionaction org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1711) org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1556) com.opensymphony.xwork2.util.classloaderutil.loadclass(classloaderutil.java:152) com.opensymphony.xwork2.objectfactory.getclassinstance(objectfactory.java:108) com.opensymphony.xwork2.objectfactory.buildbean(objectfactory.java:161) com.opensymphony.xwork2.objectfactory.buildbean(objectfactory.java:151) com.opensymphony.xwork2.objectfactory.buildaction(objectfactory.java:121) com.opensymphony.xwork2.defaultactioninvocation.createaction(defaultactioninvocation.java:300) com.opensymphony.xwork2.defaultactioninvocation.init(defaultactioninvocation.java:400) com.opensymphony.xwork2.defaultactionproxy.prepare(defaultactionproxy.java:194) org.apache.struts2.impl.strutsactionproxy.prepare(strutsactionproxy.java:63) org.apache.struts2.impl.strutsactionproxyfactory.createactionproxy(strutsactionproxyfactory.java:39) com.opensymphony.xwork2.defaultactionproxyfactory.createactionproxy(defaultactionproxyfactory.java:58) org.apache.struts2.dispatcher.dispatcher.serviceaction(dispatcher.java:501) org.apache.struts2.dispatcher.ng.executeoperations.executeaction(executeoperations.java:77) org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter.dofilter(strutsprepareandexecutefilter.java:91)
and easy see localhost:8080/myprojectname/admin/adminaction.action(it doesn't exist)
caught <action name="*_*" class="net.org.cc.{1}action" method="{2}">
in configuration above mapping created action name adminaction
, namespace /admin
. that's why you'd gotten exception because action config matchers found action config patten "*_*"
. can't find pattern "*__*"
same action name. fallback default namespace ""
, in namespace matches "**"
pattern result error page.
actually action name created 2 similar matcher , 1 of them did match. matcher created , pattern used?
the default runtime comfiguration implementation uses parameter loosematch
hardcoded true
. there's desctiption in javadoc
patterns can optionally matched "loosely". when end of pattern matches *[^*]*$ (wildcard, no wildcard, wildcard), if pattern fails, matched if lastly 2 characters didn't exist. goal back upwards legacy "*!*" syntax, "!*" optional.
and @quaternion mentioned in comment, matcher paterrn *
added list. else described earlier.
java struts2 struts url-mapping wildcard-mapping
No comments:
Post a Comment