从标题中可以看出,问题是:
RewriteCond %{SERVLET_PATH} ^/(.+)
RewriteRule ^/(.+) /home.action [L]
- >然后,如果我键入domain.com/blahblah,则将执行home.action
但是如果:
RewriteCond %{SERVLET_PATH} ^/
RewriteRule ^/ /home.action [L]
- >然后我输入domain.com - > home.action永远不会被执行!
我使用了index.jsp(并在web.xml中声明)并添加:
response.sendRedirect("home.action");
无法正常工作
然后添加:
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=home.action">
无法正常工作
因此,我将很高兴听到您的解决方案,只需键入没有任何路径的域网址即可执行操作。如:domain.com
提前致谢。
答案 0 :(得分:1)
看起来您正在使用根上下文。因此,通过转到http://www.domain.com/home.action
?
如果是,那么您可以将HomeAction
配置为struts.xml中的默认操作。
示例强>
<action name="home" class="...">
...
</action>
<default-action-ref name="home"/>
然后,如果您仅请求http://www.example.com/
,则应该调用您的主页操作。
答案 1 :(得分:0)
<强>解决强>
不要写条件,只是这个 - &gt;
RewriteRule ^/index$ /home.action [L]
你的index.jsp应该是:
<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>