Struts 2 + urlrewrite 的问题,急,急,急!

dragonsky_w dragonsky_w 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
最近项目中要用到urlrewrite的技术,可是我按照网上找的资料配置,
当我直接访问 http://localhost:8080/Mysite/html 时确实可以直接链接到 admin/目录下的index.jsp文件,该文件是用户输入用户名密码的表单,但是就在登录的时候即提交表单时,因为要跳转至一个action,结果就不成功,我就郁闷了,各位大哥帮帮忙看看那里的问题……

web.xml代码如下:

<!-- URL Rewrite Filter -->
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>WARN</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Struts 2 Filter -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>


WEB-INF/urlrewrite.xml代码如下:

<urlrewrite>

<rule>
<note>
The rule means that requests to /test/status/ will be redirected to
/rewrite-status
the url will be rewritten.
</note>
<from>/test/status/</from>
<to type="redirect">%{context-path}/rewrite-status</to>
</rule>

<outbound-rule>
<note>
The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
the url /rewrite-status will be rewritten to /test/status/.

The above rule and this outbound-rule means that end users should never see the
url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks
in your pages.
</note>
<from>/rewrite-status</from>
<to>/test/status/</to>
</outbound-rule>

<rule>
<from>^/html</from>
<to>/admin/</to>
</rule>

<rule>
<from>^/html/user/login/index.html</from>
<to>/admin/userInfo_userLogin.action</to>
</rule>

</urlrewrite>


admin/index.jsp 代码如下:

<!--
原本应该是:
<form name="loginForm" onsubmit="return checkLogin()" action="userInfo_userLogin.action" method="post">

-->
<form name="loginForm" onsubmit="return checkLogin()" action="user/login/index.html" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="31%" height="35" class="login-text02">用户名:<br /></td>
<td width="69%"><input name="loginName" id="loginName" type="text" size="29" value="admin" style="width:200px;"/></td>
</tr>
<tr>
<td height="35" class="login-text02">密  码:<br /></td>
<td><input name="passWord" id="passWord" type="password" size="30" value="123456" style="width:200px;"/></td>
</tr>
<tr>
<td height="35"> </td>
<td><input type="submit" class="right-button01" value="确认登陆"/>      
<input type="reset" class="right-button02" value="重 置" /></td>
</tr>
<tr>
<td height="35" colspan=2 align="center">            
<span style="color:red;font-size:14px;font-weight:bold;" id="errorMsg">${loginMsg} <% session.removeAttribute("loginMsg"); %> </span></td>
</tr>

</table>
</form>


原本访问 http://localhost:8080/MySite/admin 直接进入登录表单录入界面,在提交表单后,正确跳转后url地址为:
http://localhost:8080/MySite/admin/userInfo_userLogin.action 进入跳转后的页面。

而现在访问 http://localhost:8080/MySite/html 也可以同时进入登录表单录入界面,但是在提交表单后,url地址为:
http://localhost:8080/MySite/user/login/index.html 同时页面报404错误,
说找不到 HTTP Status 404 - /MySite/user/login/index.html

究竟是什么问题,拜托各位大哥帮帮忙解决一哈,谢谢了!!!!
...全文
评论 18
收藏 已收藏
分享
返回顶部
dragonsky_w
Web 开发 81,108 成员 341,721 内容