aspose file tools*
The moose likes Struts and the fly likes struts2 package tag namespace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 package tag namespace" Watch "struts2 package tag namespace" New topic
Author

struts2 package tag namespace

sarada bokka
Ranch Hand

Joined: Jan 13, 2010
Posts: 80
Hi All,

In struts.xml i have included 2 files

<include file="/com/tricky/vo/user.xml"/>
<include file="/com/tricky/vo/project.xml"/>

user.xml uses namespace
tricky

project.xml uses namespace
project


My welcomepage hits the url http://localhost:8080/struts2-login/tricky/showLogin.action from this page i tried to call another action which is having different package name

but the thing is when i am trying to hit , tricky namespace tries to append to url as http://localhost:8080/struts2-login/tricky/project/createproject.action

I want the URL to be like this http://localhost:8080/struts2-login/project/createproject.action (without tricky namespace)

in my jsp i tried to call my action with different options to remove tricky
1) project/createproject
2) /project/createproject
3)../project/createproject

Thanks in advance.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

There's no reason to use "quote" tags around single words. Just put things like that in actual "quotes".

You neglected to mention how you're creating the URLs. If you're using the <s:url> tag and creating a link to an action in another namespace you'll need to use the "namespace" attribute.
sarada bokka
Ranch Hand

Joined: Jan 13, 2010
Posts: 80
Thanks for the info.

I am using <s:a action="../project/createproject">create project</s:a>
sarada bokka
Ranch Hand

Joined: Jan 13, 2010
Posts: 80
Hi David,

You mean to try like the below

<s:url namespace="/project" action="createproject">create project</s:url>

This doesn't help me
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I find that unlikely, but okay. Please post your configuration files and the hierarchy of deployed JSPs.
sarada bokka
Ranch Hand

Joined: Jan 13, 2010
Posts: 80
Hi David,

It's working fine.

I have incorporated your inputs of namespace to anchor tag.

<s:a namespace="/project" action="createproject" >create project</s:a>
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oh, right; I didn't even see the wrong tag was being used! Glad you got it working.
Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 83

i am real newbie to struts... why do we use the namespace attribute in the package tag?\

if i remove the namespace attribute i get the following error.

Aug 26, 2012 7:54:55 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: Y:\Program Files\Java\jre7\bin;Y:\Windows\Sun\Java\bin;Y:\Windows\system32;Y:\Windows;Y:/Program Files/Java/jre7/bin/client;Y:/Program Files/Java/jre7/bin;Y:/Program Files/Java/jre7/lib/i386;Y:\oraclexe\app\oracle\product\11.2.0\server\bin;;Y:\Windows\system32;Y:\Windows;Y:\Windows\System32\Wbem;Y:\Windows\System32\WindowsPowerShell\v1.0\;Y:\eclipse-jee-indigo-SR2-win32\eclipse;;.
Aug 26, 2012 7:54:56 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.serveremoStruts' did not find a matching property.
Aug 26, 2012 7:54:56 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-5000
Aug 26, 2012 7:54:56 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 442 ms
Aug 26, 2012 7:54:56 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Aug 26, 2012 7:54:56 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
Aug 26, 2012 7:54:56 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register
INFO: Parsing configuration file [struts-default.xml]
Aug 26, 2012 7:54:56 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register
INFO: Parsing configuration file [struts-plugin.xml]
Aug 26, 2012 7:54:56 PM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register
INFO: Parsing configuration file [struts.xml]
Aug 26, 2012 7:54:56 PM org.apache.struts2.config.Settings getLocale
WARNING: Settings: Could not parse struts.locale setting, substituting default VM locale
Aug 26, 2012 7:54:56 PM com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory <clinit>
INFO: Setting DefaultObjectTypeDeterminer as default ...
Aug 26, 2012 7:54:56 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-5000
Aug 26, 2012 7:54:56 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Aug 26, 2012 7:54:56 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16 config=null
Aug 26, 2012 7:54:56 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 766 ms
Aug 26, 2012 7:54:58 PM org.apache.struts2.components.Form evaluateExtraParamsServletRequest
WARNING: No configuration found for the specified action: 'hello' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
Aug 26, 2012 7:54:58 PM org.apache.struts2.components.Form evaluateExtraParamsServletRequest
WARNING: No configuration found for the specified action: 'hello' in namespace: ''. Form action defaulting to 'action' attribute's literal value.


my struts.xml file is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts SYSTEM "struts-2.0.dtd" >
<struts>

<package name="mypack" namespace="/DemoStruts" extends="struts-default">


<action name="hello" class="com.actionclass.LoginAction">

<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>

</struts>
 
 
subject: struts2 package tag namespace