java访问地址栏通过urlrewrite跳转

如果是urlrewite:

<rule>
		<from>(.*?)/admin/$</from>
		<to type="redirect">./login.jspx</to>
	</rule>


配置文件web.xml中:

 <filter>
  <filter-name>UrlRewriteFilter</filter-name>
  <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
  <init-param>
   <param-name>logLevel</param-name>
   <param-value>INFO</param-value>
  </init-param>
  <init-param>
   <param-name>confPath</param-name>
   <param-value>/WEB-INF/classes/conf/urlrewrite.xml</param-value>
  </init-param>
  <init-param>
   <param-name>confReloadCheckInterval</param-name>
   <param-value>60</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>UrlRewriteFilter</filter-name>
  <url-pattern>/*</url-pattern>
  <dispatcher>REQUEST</dispatcher>
  <dispatcher>FORWARD</dispatcher>
 </filter-mapping>




当访问的路劲为:localhost:8080/admin


它会自己跳转到:localhost:8080/admin/login.jspx上


如果jsp页面,那么就是<jsp:forword page=""></jsp:forword>:

<jsp:forward page="${basePath}/front/admin/index.jspx"></jsp:forward>


去掉尾巴:首先在web.xml中配置首页的地址,index.jsp或者index.html

<welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
  <welcome-file>index.html</welcome-file>
 </welcome-file-list>


然后在index.jsp中搞个jsp:forword,那么通过域名访问,比如http://www.test.com,它找到index.jsp,然后一定向就找到你的action,


那么那就可以在action中做自己的处理,又不带尾巴》。。。





你可能感兴趣的:(urlwrite,jspforword)