Struts2的jsp和action路径解决方案

来源:互联网 发布:js 点击跳框 编辑:程序博客网 时间:2024/05/20 23:39

Index.jsp:

 

<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();

 

//jsp配置绝对路径(如果不是在跟目录下可以在'/'后面添加你的文件夹名称)
String jspPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

 

//action配置绝对路径('/asd/'是我自己设置的namespace名称)
String actionPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/asd/";


%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <!--<base href="<%=basePath%>">-->
   
    <title>My JSP 'index.jsp' starting page</title>
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
  </head>
 
  <body>

    <!-- action绝对路径的写法-->
    <a href=<%=actionPath%>hello.action>ActionLink</a><br>

 

    <!-- jsp绝对路径的写法-->
   
<a href==<%=jspPath%>Helllo.jsp>JspLink</a><br>


  </body>
</html>

 

原创粉丝点击