Struts2 的路径

interceptors  总共35个拦截器,底层默认执行20个拦截器

后台:  / 当前应用的根路径

前台: 前/ 相对路径

解析完毕后的效果

       后台路径:http://localhost/02-path/

       前台路径:http://localhost/02-path/test/login[/02-path/test/login中/代表http://localhost]

如果对比成功,则跳转成功

4种方法:

1:缺省项目名

2:/获取前台路径

3:通过el表达式获取项目名称

4:通过basePath 获取路径 

 <!--前台:缺省/ 是相对路径写法 参照的是服务器的根路径  -->

  <!--前台提交路径发生变化 namespace/name  -->

   <!--  <form action="test/Login" method="post">

    用户名:<input type="text" name="username">

    密&nbsp;码:<input type="password" name="password">

    <input type="submit" value="提交">

    </form> 

    <!-- 前台/写法 :代表服务器的根路径 [http://localhost/--struts.xml](http://localhost/--struts.xml)对一下

    跳转路径:404 ?/test/Login 缺少项目名称

    现在路径:http:localhost/02-psth/test/login 
                  :http:localhost/项目名/namespace/action的name
<package name="xxx" namespace="/test" extends="struts-default">
<action name="login" class="com.lanou.entity.LoginAction">
    -->

   

   <%--   <form action="${pageContext.request.contextPath}/test/Login" method="post">

    用户名:<input type="text" name="username">

    密&nbsp;码:<input type="password" name="password">

    <input type="submit" value="提交">

    </form> --%>

   

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

      test/Login” method=”post”>

    用户名:

    密 码:

   

   

猜你喜欢

转载自blog.csdn.net/qq_31334119/article/details/80097231