urlwrite的书写。

<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>

这几天没什么事情做,由于我现在在做博客系统,所以就找了一些资料预备以后使用。今天感觉把动态链接生成静态链接这种技术还是蛮不错的, 于是上网找了一下。urlwrite 这个字眼落入我的眼中起初不明白是什么东西。后来在网上一艘有好多介绍他的网页, 大致的意思就是把动态的地址转换成静态的地址,增大搜索引擎化,我解释的不是很明白,大致就是这样的吧, 下面给大家一个小例子,大家需要帮助多的看看。。

indexx.jsp:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<header>
<title>world</title>
</header>
<body>
<%
String country = request.getParameter("country");
String city = request.getParameter("city");
out.write("Country=" + country);
out.write("<br>city=" + city);
%>
<a href="<%=request.getContextPath()%>/world/1/2">test</a>
</body>
</html>
urlrewrite.xml :(和web.xml同级)

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
" http://tuckey.org/res/dtds/urlrewrite3.0.dtd">

<urlrewrite>

<rule>
<from>/world/(\w+)/(\w+)</from>
<to>/indexx.jsp?country=$1&amp;city=$2</to>
</rule>
</urlrewrite>

web.xml:
<display-name>url rewrite filter build</display-name>
<description>build context</description>

<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>confReloadCheckInterval</param-name>
<param-value>30</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
<init-param>
<param-name>statusEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>statusPath</param-name>
<param-value>/status</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

然后再需要的就是 一个包, 你去网上一艘就能搜的到,然后你运行这个程序,你看见indexx.jsp那两个值会由null转化为 1 和 2 ,但是地址确实静态的, 这个就是urlwrite的作用吧。。。。

你可能感兴趣的:(html,jsp,Web,xml,搜索引擎)