everyone. I'm having problem on struts2 namespace..
First of all, this is my developing environment.
server : tomcat
(currently my project is in ROOT
folder in /tomcat/webapps/ROOT
)
framework : struts2
Here is my problem. lets say there are two pages. admin_index.jsp and front_index.jsp when i want to call admin_index.jsp from action. i use
<package name="admin" namespace="/dl_adm" extends="struts-default">
<action name="/index" method="index"class="kr.co.www2.controller.front.AdminMainController">
<result name="success">/WEB-INF/jsp/admin/admin_index.jsp</result>
</action>
</package>
and it works fine by calling http://.../dl_adm/index.do
and to call this has problem for me.
<package name="front" namespace="/" extends="struts-default">
<action name="/index" method="index"class="kr.co.www2.controller.front.FrontMainController">
<result name="success">/WEB-INF/jsp/admin/front_index.jsp</result>
</action>
</package>
when i go for the http://.../index.do
, it gives 404...
although i aware that namespace="/"
is for default namespace...
QUESTIONS:
Is there anyway to ignore the default namespace? because i want to use that /
because i just want to go through http://.../
and action name without namespace...
or if there isn't a way to do that. any suggestions?
- Is there anyway to ignore the default namespace? because i want to use that / because i just want to go through
http://.../
and action name without namespace..
No, you can't ignore the default namespace. The default namespace is empty and it's used if you omit namespace
attribute in the package declaration.
- or if there isnt a way to do that. any suggestions?
I would not use slashes in action name using xml configuration. The action mapper might incorrectly add an additional slash to the action name to infer the mapping from the URL.
So you should use
<package name="front" namespace="/" extends="struts-default">
<action name="index" method="index"class="kr.co.www2.controller.front.FrontMainController">
<result name="success">/WEB-INF/jsp/admin/front_index.jsp</result>
</action>
</package>