index.jsp
<%@ page language="java" import="java.util.*" import="pack1.filter1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!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">
-->
<script language="javascript">
function fun(){
<%
out.print("fdasf");
%>
}
</script>
</head>
<body>
This is my JSP page. <br>
<a href="first!jia">tianjiao</a>
<a href="first!geng">gengxin</a>
</form>
<font color="red">
<s:property value="info"/>
</font>
</body>
</html>
配置下struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<!-- 声明包 -->
<package name="myPackage" extends="struts-default">
<!-- 定义action -->
<action name="first" class="pack1.filter1">
<!-- 定义处理成功后的映射页面 -->
<result name="jia">/user.jsp</result>
<result name="geng">/geng1.jsp</result>
</action>
</package>
</struts>
Note:
href=”<%=basePath%>”>