struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Haulyn R. Jason" <saharab...@gmail.com>
Subject Re: Issue with Url mapping with struts-action-extension=""
Date Thu, 07 Aug 2008 03:42:19 GMT
Jeromy Evans 写道:
> Haulyn R. Jason wrote:
>   
>>>     > In case it is a, I would try the following settings:
>>>     >
>>>     > struts.action.extension=,,action
>>>     >
>>>
>>>     
>>>       
>> 2.If I use Evans' way, it looks worked well but just need a "."..Struts
>> do not have a solution for these?
>>
>> Thanks
>>
>>   
>>     
>
> I thought this was supported by this version of Struts 2 but I never use
> the DefaultActionMapper so I maybe a problem does exist there.
>
> To fix:
> 1 create a custom action mapper copied from DefaultActionMapper.java
> [link below]
> 2. enable it in struts.properties or struts.xml : ie.
> struts.mapper.class = com.PatchedDefaultActionMapper
> 3. Apply a patch to the dropExtension method that accepts blank
> extensions. Here is the updated method:
>
> /**
> * Drops the extension from the action name
> *
> * @param name
> * The action name
> * @return The action name without its extension
> */
> String dropExtension(String name) {
> if (extensions == null) {
> return name;
> }
> Iterator it = extensions.iterator();
> while (it.hasNext()) {
> String value = (String) it.next();
> if (value.length() > 0) {
> String extension = "." + value;
> if (name.endsWith(extension)) {
> name = name.substring(0, name.length() - extension.length());
> return name;
> }
> } else {
> // allow a blank extension
> if (!name.contains(".")) {
> return name;
> }
> }
> }
> return null;
> }
>
> regards,
> Jeromy Evans
>
> [source]
> http://svn.apache.org/viewvc/struts/struts2/tags/STRUTS_2_0_11_1/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java?view=markup
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   
Thanks Evans, it works well, but I decide to give up!

When I supply your solution, everything work well. But I found all the
urls , when I use <s:url action="" /> , all actions are added a
extension "." by struts. So I add
// allow a blank extension
if (!name.contains(".")) {
return name;
}else if(name.endsWith(".")){
return name.substring(0, name.lastIndexOf("."));
}
}
to your code.
But Some other thing does not work. maybe it's value stack issue, I am
not sure.

So, I will give up. I will not try to remove extensions for struts2 and
use "jsps" instead of "action".

Always thank you Evans and everyone who helped me. Thanks!

-- 

Thanks!

Mobile: +086-15864011231
EMail&gtalk:saharabear@gmail.com
EMail&yahoo:jia_haolin@yahoo.com
Skype:saharabear


贾昊林(Haulyn Runner Jason)


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


Mime
View raw message