http://www.lunatech-research.com/archives/2005/07/29/struts-urls
Many web applications inelegantly expose themselves in their
URLs. While ASP.NET applications tend to have an .aspx
in the URL, Struts’ default configuration gives you a
.do
in your URL. It is possible to reconfigure a
Struts
web application that
uses URLs like
/customer.do?method=edit&id=42
to use
something like /customer/edit/42
instead. This article
covers several separate techniques that you can use for different
parts of the URL.
Remove the .do
The first step is to remove the redundant .do
from
the URL. After all, MIME Content-type
headers
mean that web resources do not need ‘file
extensions’ to indicate their type.
The .do
is there to map certain URLs to the Struts
ActionServlet, which is achieved by the following
web.xml
entries:
action
org.apache.struts.action.ActionServlet
action
*.do
The most obvious option is to replace the Servlet mapping’s
extension mapping to a prefix mapping like
/do*"
type="com.example.web.{1}Action" parameter="{2}"
/>
The asterisks match paths like /customer/
or
/customer/edit
. The first downside is that if you want
to have lower-case URLs then the action class needs to be called
customerAction
instead of CustomerAction
- legal but unconventional. Still, I personally think it would be
worse to include upper-case letters in the URL, although that is
probably
unavoidable with form parameter names later on.
The second asterisk is something like ‘view’ or ‘edit’ -
the DispatchAction
method name. The standard approach
is to say
parameter="method"
in the action mapping and then
specify the method in the URL with method=edit
.
With the wildcards in the mapping, you can just get the method
name from the URL and specify it in as the parameter directly by
using parameter="{2}"
in the mapping configuration.
Then all you need to do is override the
DispatchAction.getMethodName
method with:
protected String getMethodName(ActionMapping m, ActionForm f,
HttpServletRequest req, HttpServletResponse res, String p) throws Exception
{
return parameter;
}
This means that that Struts calls the method in your action
class whose name is the parameter
value in the action
mapping, which in turn is the second part of the path.
Now you can use
/customer/edit&id=42
instead of
/customer?method=edit&id=42
.
An advantage of this scheme is that you can use the same
wildcard parameters to specify the form name and the JSP path for
forwards. For example, if you use the mapping:
Perfect.
分享到:
相关推荐
The URL extension to use to determine if the request is meant for a Struts action 用URL扩展名来确定是否这个请求是被用作Struts action,其实也就是设置 action的后缀,例如login.do的'do'字。 struts....
By default, ASP.NET Core apps listen on the following URLs: http://localhost:5000 https://localhost:5001 In this post I show 5 different ways to change which URLs your app listens on. There are ...
Efficient summarization of URLs using CRC32 for implementing URL switching
ultimate_seo_urls Url规则也就越少
AxureRP-extension-for-Chrome-0.6.2 Chrome Version 33.0.1750.146 m 因为众所周知的原因,此插件不能正常下载,但是可以通过离线安装 使用说明: 1 设置---更多工具--扩展程序 2 打开开发者模式 3 加载已解压的...
Urls for Humans 是一个 gem,它允许您利用Model.find(params[:id]) 、 to_i和to_param发生的事情,为 Rails 应用程序的 url 应用有意义的名称。 这使得将users/1为users/1-john-otander 。 只要 url 以模型的id为...
zencartultimate_seo_urls安装说明.pdf
Zencart必备插件之一ultimate_seo_urls,好的SEO优化必须需要规范URL,ultimate_seo_urls为Zencart提供URL重写功能。
Chrome插件-Copy All Urls优雅地保存-开启多个标签页.zip。Copy All Urls属于小而美地工具,如果你每天都需要查看几个固定的网页, Copy All Urls能帮你省很多时间。
资源内容:Copy-All-Urls_v2.10.crx。解决一次性复制谷歌浏览器所有标签网址的问题。释放双手。 使用方法:安装谷歌chrome浏览器》下载文件双击打开安装
python struts-pwn.py --list 'urls.txt' -c 'id' 检查针对单个URL的漏洞是否存在。 python struts-pwn.py --check --url 'http://example.com/struts2-showcase/index.action' 根据URL列表检查漏洞是否存在。 ...
的优化插件ultimate_seo_urls的使用,以及站内优化
一个数据挖掘与知识学习方面的论文 针对网页增加简单标题方面的文章
语言:English 如果您想在VLC中播放此视频扩展名,它将有助于获取实际的视频URL。 如果您想在VLC中播放此视频扩展名,它将有助于获取实际的视频URL。 ... 只需复制它,然后在VLC媒体播放器中粘贴“媒体->打开网络流”,...
curl for windows10 x64 , version Version 7.56.1 (23 Oct 2017) ... 'default' like the URLs for the browser are. Closes #1998 - imap: if a FETCH response has no size, don't call write callback
基于我之前写的代码,这个文件用于储存事先requests得到的图集链接,直接保存到代码同级目录以运行代码
资源来自pypi官网,解压后可用。 资源全名:d8s_urls-0.6.0-py2.py3-none-any.whl
本源码主要帮助读者更好的阅读博客,小编的博客地址: https://blog.csdn.net/aiming66/article/details/81626232
如果你想在VLC中播放,这个扩展将有助于获得实际的视频URL 如果您想在VLC中播放此视频扩展名,它将有助于获取实际的视频URL。 ... 只需复制它,然后在VLC媒体播放器中粘贴“媒体->打开网络流”,然后在线观看您喜欢...
打开URL列表源代码:https://github.com/htrinter/Open-Multiple-URLs/ Changelog:https://github.com/htrinter/Open-Multiple-URLs/blob/v1.5.0/CHANGELOG。 md权限:-“制表符”权限以打开新标签页。 该权限显示...