码迷,mamicode.com
首页 > 其他好文 > 详细

伪静态

时间:2018-05-22 17:17:02      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:write   coding   rewrite   for   页面   new   href   http   html   

使用urlrewritefilter-4.0.3.jar
配置web.xml

  <!-- 伪静态 -->
  <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>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>
在web.xml同级目录新建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>^/web/news/newsCenter.html$</from>
                <to type="forward">/web/news/newsCenter.do</to>
              </rule>
<!-- 新闻中心结束 -->
<!-- 新闻详细页开始 -->
              <rule>
                <from>^/web/news/newsParticular/n_id_([-]?[0-9a-zA-Z]+)?/news_type_([-]?[0-9a-zA-Z]+)?.html$</from>
                <to type="forward">/web/news/newsParticular.do?nId=$1&amp;newsType=$2</to>
              </rule>
<!-- 新闻详细页结束 -->
</urlrewrite>
页面

<body>
  <div class="content-right fr">
                <div class="content-right-tit">
                    <img src="web/img/t34.jpg"/>
                </div>
    <div class="content-right-con">
                    <div class="news">
                        <div class="news-con1">
                            <p>企业公告</p>
                            <ul>
                                <c:forEach var="item" items="${corporateActionsLists }" >
                                    <li >
                                        <c:url value="/web/news/newsParticular/n_id_${item.id}/news_type_${item.newsType}.html" var="tempNewsUrl"></c:url>
                                        <a href="${tempNewsUrl} ">${item.newsTitle }</a><span>发布时间:<i><fmt:formatDate value="${item.releaseTime }" pattern="yyyy-MM-dd"/></i></span>
                                    </li>
                                </c:forEach>
                            </ul>
                        </div>
                        <div class="news-con2">
                            <p>行业新闻</p>
                            <ul>
                                <c:forEach var="item" items="${tradeNewsLists }" >
                                    <li>
                                        <c:url value="/web/news/newsParticular/n_id_${item.id}/news_type_${item.newsType}.html" var="tempNewsUrl"></c:url>
                                        <a href="${tempNewsUrl}">${item.newsTitle }</a><span>发布时间:<i><fmt:formatDate value="${item.releaseTime }" pattern="yyyy-MM-dd"/></i></span>
                                    </li>
                                </c:forEach>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
  </body>

技术分享图片

 

伪静态

标签:write   coding   rewrite   for   页面   new   href   http   html   

原文地址:https://www.cnblogs.com/yang1018/p/9072898.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!