As you see from the title, the problem is:
RewriteCond %{SERVLET_PATH} ^/(.+)
RewriteRule ^/(.+) /home.action [L]
-> then if I type domain.com/blahblah the home.action will be executed
However if:
RewriteCond %{SERVLET_PATH} ^/
RewriteRule ^/ /home.action [L] 开发者_JAVA技巧
-> then I type domain.com -> home.action never be executed!
I used an index.jsp (and declare in web.xml as well) and add:
response.sendRedirect("home.action");
DIDN'T work
Then add:
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=home.action">
DIDN'T work
As a result, I would be appreciated to hear your solutions in order to execute an action by only type the domain url without any path. Such as: domain.com
Thanks in advance.
It looks like you are using a root context. Therefore, would it be safe to say that you would normally access your action by going to http://www.domain.com/home.action
?
If so, then you can configure HomeAction
as the default action in your struts.xml.
Example
<action name="home" class="...">
...
</action>
<default-action-ref name="home"/>
Then, if you request just http://www.example.com/
, it should invoke your home action.
Solved;
Don't write a condition, just only this ->
RewriteRule ^/index$ /home.action [L]
And your index.jsp should be:
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-9" />
<meta name="verify-v1" content="tonewfwefwewfwefwefrz4tqvroPwefewfy3izuwefwefKs=" />
<meta http-equiv="refresh" content="0;url=" />
</head>
<body>
<%
response.setStatus(301);
response.setHeader( "Location", "/" );
response.setHeader( "Connection", "close" );
%>
</body>
精彩评论