Struts 2 + urlrewrite 的问题,急,急,急!
最近项目中要用到urlrewrite的技术,可是我按照网上找的资料配置,
当我直接访问 http://localhost:8080/Mysite/html 时确实可以直接链接到 admin/目录下的index.jsp文件,该文件是用户输入用户名密码的表单,但是就在登录的时候即提交表单时,因为要跳转至一个action,结果就不成功,我就郁闷了,各位大哥帮帮忙看看那里的问题……
web.xml代码如下:
WEB-INF/urlrewrite.xml代码如下:
admin/index.jsp 代码如下:
原本访问 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
究竟是什么问题,拜托各位大哥帮帮忙解决一哈,谢谢了!!!!
当我直接访问 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
究竟是什么问题,拜托各位大哥帮帮忙解决一哈,谢谢了!!!!
...全文
相关推荐
Struts2下使用urlReWrite的最简实例(MyEclipse工程)
**添加Struts2和urlRewrite依赖** - Struts2的核心库包括struts2-core.jar,可以通过Maven或直接下载JAR包添加到项目的类路径中。
使用urlrewrite重写struts2的action
例如,如果你想将`/struts2示例.action?
ssh2中的urlrewrite和Struts2的生成静态页面
### SSH2中的URLRewrite与Struts2生成静态页面#### URLRewrite的理解与应用在SSH2(Spring + Struts2 + Hibernate)框架中,URLRewrite
UrlRewrite例子
Struts2是一个流行的MVC框架,它的Action机制允许开发者通过不同的URL来调用不同的业务逻辑。然而,Struts2默认的URL格式往往包含了很多不必要的参数,不利于搜索引擎抓取和用户记忆。
伪静态URLRewrite实例解析
DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN" "http://tuckey.org/res/dtds/urlrewrite2.6


Web 开发
