大家好, 我现在做好了一个JSP页面,但是他上面的包太多,访问时要写一大串路径如:http://localhost:8888/pms/pages/vehicle/index/index.jsp,有没有一种方法让我在访问这个JSP时不要写那么多路径如:http://localhost:8888/pms/pages/index.jsp,有没有这样的技术了? 谢谢
我用的是struts2 + spring +hibernate写的

解决方案 »

  1.   

    可以用Tuckey UrlRewriteFilter实现。
    网址在:http://tuckey.org/urlrewrite/
      

  2.   

    那struts.xml中的namespace的作用是什么了,可不可以做成这个功能,以及他是怎么访问的?
      

  3.   

    namaspac可以做到
    例如定义一个action的namaspac为/
    成功结果页为http://localhost:8888/pms/pages/vehicle/index/index.jsp
    直接用http://localhost:8888/pms/xxx.action访问就行了
      

  4.   

    类似默认主页跳转?<meta http-equiv="Refresh" content="0;URL=/sss.action">=============================================sss.action  -->  /pages/vehicle/index/index.jsp=============================================输 http://localhost:8888/pms/sss.action
    自动转到 http://localhost:8888/pms/pages/vehicle/index/index.jsp
      

  5.   

    你也可以把这个路径写在action里面 当成一个参数传到配置文件中去 这样更方便!
      

  6.   

    如果是主页面的话,可以在配置文件中配置一下<welcome-file-list>的访问路径,也可以用action处理
      

  7.   

    可以创建一个servlet来对请求的url做映射
    思路这样:
    建一个Servlet在doGet中接收参数 go RequestDispatcher dispatcher = null;
    String param = request.getPrameter("go");
    if(param == null) 
        thorw new ServletException("Missing parameter.");
    else if(param.equals("index")) {
        dispatcher = request.getDispatcher("/pms/pages/vehicle/index/index.jsp");
    }
    ....加入你要的其他路径
    if(dispatcher != null) {
        dispatcher.forward(request, response);
    }
    else 
        throw new ServletException("null dispatcher.");个人想法希望对你有帮助.
      

  8.   

    呵呵 ,业务要求啊,  要求做一个独立的JSP
      

  9.   

    <welcome-file-list>
    <welcome-file>vehicle/index/index.jsp</welcome-file>
    </welcome-file-list>
    访问时用http://localhost:8888/pms/pages
    还有楼主可以说说,这么做具体要实现什么样的功能,针对不同的情况,处理的
    方式也是不一样的
      

  10.   

    配置文件中配置
    <action name="**" class="cms.cmsPage" method="{1}">
    <result name="yes" type="dispatcher">${path}</result>
    <result name="action" type="chain">
    <param name="namespace">${namespace}</param>
    <param name="actionName">${actionName}</param>
    </result>
    </action>
    path namespace actionName都可以在action中配置 当然你的提议只设置path就可以了