请问我原路径是front.do?method=show 
我用urlrewritefilter重写成front.html
<head>
<meta http-equiv="refresh" content="0;url=front.html">
#原来的是<meta http-equiv="refresh" content="0;url=front.do?method=show">
</head
<rule>
<note>
进入首页
</note>
<from>^front.html</from>
<to>front.do?method=show</to>
</rule>
报404错误,请问我改怎么写?还有,如果我是
<html:link page="/userAccount.do?method=selgetMoneyAll&pageDo=first">
<html:link page="/userAccount.do?method=selgetMoneyAll&pageDo=first&aa=aa&bb=bb">
这两条条路径应该怎么写?,aa和bb是变量噢
本人有点笨,看不懂那些规则,希望有朋友能帮我写下

解决方案 »

  1.   

    <html:link page="<%=request.getContextPath()%>/userAccount.do?method=selgetMoneyAll&pageDo=first&aa=aa&bb=bb"> 
      

  2.   

    既然你已经配置了rewrite,
    在提交的时候就要提交“化妆后”的,
    也就是<from>定义的那个url所有的url都是,
    这样通过rewriter才能变成真正的url。good luck
      

  3.   

    贴个文档给lz参考,
    http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.2/index.html#configuration简单的说,
    $1$2就是匹配from里的第一个正则表达式和第二个,
    如果是通配符的话,也是说第一个第二个,比如:<rule>
               <from>^/some/olddir/(.*)$</from>
               <to type="redirect">/very/newdir/$1</to>
            </rule>这里的$1就代表
    “/very/newdir/”下的所有动作对应“/some/olddir/”路径下的所有请求比如
    /very/newdir/a.jsp
    就会“转”给/some/olddir/a.jspgood luck
      

  4.   

    还是不懂,我下面的原路径需要传参,看到很多例子都是不带参数的,我下面的不知道怎么去重写
    <html:link page="/front.do?method=newlist&ID=1&news_id=${element.news_id}">${element.news_Title}</html:link>
      

  5.   

    比如:
    from里面是
    /some/(.*)$/(.*)$/(.*)$.html
    to里面是
    /yourserver/$1/$2/$3.do那么当浏览器里的url是
    /some/earth/asia/china.html
    的时候
    实际上就可以看作是对
    /yourserver/earch/asia/china.do
    的请求或者
    /some/earth/asia/japan.html
    的时候
    实际上就可以看作是对
    /yourserver/earch/asia/japan.do
    的请求
    就是逐一替换的意思。然后,lz在struts-config.xml里面,
    配置这个china.do的action就行了。也就是说...就是替换,
    至于怎么替换lz不用管,
    lz就处理to的那个url就可以了。good good luck luck
      

  6.   

    所以lz的
    /front.do?method=newlist&ID=1&news_id=${element.news_id}"
    是转换后的url,
    也就是to的。那个filter是根据from来对比url,再去找to的处理的所以这个url要变成from的形式,
    类似...
    别类似了,给lz一个参考吧
    <from>
    /front/method_newlist/ID_l/news_id_(.*)$
    </from>
    <to>
    /front.do?method=newlist&ID=1&news_id=$1
    </to>然后那个html标签写:
    <html:link page="/front/method_newlist/ID_1/news_id_${element.news_id}">${element.news_Title} </html:link>ok?good luck
      

  7.   

    恩,我以前的估计全写错了
    以前我的一个front.do?method=show 改成 front
    <from casesensitive="false">^/front</from> 
       <to type="forward" last="true" encode="default">front.do?method=show</to> 
    结果所有有front开头的路径只要没重写的都报错
    如果是
    <from> 
    /front/method_newlist/ID_l/news_id_(.*)$ 
    </from> 
    <to> 
    /front.do?method=newlist&ID=1&news_id=$1 
    </to> 然后那个html标签写: 
    <html:link page="/front/method_newlist/ID_1/news_id_${element.news_id}/news_title_${element.news_title}">${element.news_Title} </html:link> 
    就写成
    <from> 
    /front/method_newlist/ID_l/news_id_(.*)$/news_title_(.*)
    </from> 
    <to> 
    /front.do?method=newlist&ID=1&news_id=$1&news_title=$2
    </to> 
      

  8.   

    一回生二回熟嘛呵呵good luck
      

  9.   

    又有个问题是
    <meta http-equiv="refresh" content="0;url=front/method_show">
    源路径是
    <meta http-equiv="refresh" content="0;url=front.do?method=show">
    <from casesensitive="false">^/front/method_(.*)$</from> 
    <to type="forward" last="true" encode="default">front.do?method=show</to>
    那启不是所有front.do?method=xxx都会跳到front.do?method=show里面去?
    大哥你人真好,结贴单独给你50分,呵呵。分也不多了
      

  10.   

    <meta http-equiv="refresh" content="0;url=front/method_show">
    <rule>
    <note>
    进入首页
    </note>
    <from casesensitive="false">^/front/method_(.*)$</from> 
       <to type="forward" last="true" encode="default">front.do?method=show</to> 
    </rule>
    错了...
      

  11.   

    1、meta标签不熟,不过应该是直接跳过去了。2、to的那个应该这样:
    <to type="forward" last="true" encode="default">/front.do?method=$1 </to>注意哪个要被替换的位置的$1,
    可能不知道哪部分被替换也要报错。3、servlet规范的url都要"/"开头,lz注意一下。4、正则表达式是以^开头以$结尾的,中间的()中的是“替换的部分”,
    也就是要被逐一提取出来放在$1$2这样的位置上的内容5、lz不用客气,写代码的时候知识就是要灵活掌握的。good luck
      

  12.   


    文档不错啊贴个文档给lz参考, 
    http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.2/index.html#configuration 
      

  13.   

    晕啊。。为什么
    <rule>
    <note>
    顶部导航action,进入会员中心
    </note>
    <from casesensitive="false">^/come/(.*)$</from> 
       <to last="true" encode="default">/come.do?method=$1</to> 
    </rule>重定向成功
    但是
    message = "您还未登录,请登录!";
    request.setAttribute("message", message);
    request.setAttribute("paths", "front/show");
    跳的时候http://localhost:8080/feizhang/come/front/show  ,前面多了个come?
      

  14.   

    真要疯了明明是
    <meta http-equiv="refresh" content="0;url=front/show">
    <from casesensitive="false">^/front/(.*)$</from> 
    <to type="redirect" last="true" encode="default">/front.do?method=$1</to> 开始还好的又显示成
    http://localhost:8080/front.do?method=show了
    把之前type="forward" 改成type="redirect"。。