亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

ssm框架做登錄測試時,如何把url欄中的.action偽裝變成.html?用urlrewrite這個東東。

ssm框架做登錄測試時,如何把url欄中的.action偽裝變成.html?用urlrewrite這個東東。

--urlrewrite.xml <?xml?version="1.0"?encoding="utf-8"?>???? <!DOCTYPE?urlrewrite?PUBLIC?"-//tuckey.org//DTD?UrlRewrite?2.6//EN"????"http://tuckey.org/res/dtds/urlrewrite2.6.dtd"?> <urlrewrite> <rule> <from>/index.html</from> <to?type="forward">/index.jsp</to> </rule> <rule> <from>/([a-zA-Z0-9_\u4e00-\u9fa5]+).html</from> <to?type="forward">/ssmTest/$1.action</to> </rule> </urlrewrite> --web.xml <?xml?version="1.0"?encoding="UTF-8"?> <web-app?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?xmlns="http://java.sun.com/xml/ns/javaee"?xsi:schemaLocation="http://java.sun.com/xml/ns/javaee?http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"?id="WebApp_ID"?version="3.0"> ??<context-param> ????<param-name>contextConfigLocation</param-name> ????<param-value>classpath:spring*.xml</param-value> ??</context-param> ??<listener> ????<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> ??</listener> ??<filter> ????<filter-name>struts2</filter-name> ????<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> ??</filter> ??<filter-mapping> ????<filter-name>struts2</filter-name> ????<url-pattern>/*</url-pattern> ????<dispatcher>REQUEST</dispatcher> ????<dispatcher>FORWARD</dispatcher> ??</filter-mapping> ?? ??<filter>?? ????<filter-name>UrlRewriteFilter</filter-name>?? ????<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>?? </filter>?? <filter-mapping>?? ????<filter-name>UrlRewriteFilter</filter-name>?? ????<url-pattern>/*</url-pattern>?? </filter-mapping>? <welcome-file-list> <welcome-file>index.jsp</welcome-file> <welcome-file>*.html</welcome-file> </welcome-file-list> </web-app> --struts.xml <?xml?version="1.0"?encoding="UTF-8"??> <!DOCTYPE?struts?PUBLIC "-//Apache?Software?Foundation//DTD?Struts?Configuration?2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <constant?name="struts.enable.DynamicMethodInvocation"?value="false"?/> <constant?name="struts.devMode"?value="true"?/> <!--?把struts的action對象交給spring容器管理?--> <constant?name="struts.objectFactory?"?value="spring"?/> <package?name="default"?namespace="/"?extends="struts-default"> <action?name="*_*"?class="{1}Action"?method="{2}"> <result?name="loginsuccess">page/success.jsp</result> <result?name="loginfail"?type="redirect">index.jsp</result> </action> </package> </struts>問題來了:::把localhost:8080/ssmTest/user_login.action登錄跳轉時變成localhost:8080/ssmTest/user_login.html
查看完整描述

1 回答

?
yemaa

TA貢獻77條經驗 獲得超14個贊


在web.xml配置

<filter-mapping>
??<filter-name>struts2</filter-name>
??<url-pattern>*.html</url-pattern>
?</filter-mapping>

查看完整回答
反對 回復 2016-08-12
  • 1 回答
  • 1 關注
  • 5905 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號