struts2使用标签获取当前网址

//前台代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="/struts-tags"  prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>struts标签</title>
</head>
<body>
<h3>url</h3>
	<!-- url标签是生成地址所用,注意与a标签区分 -->
	<s:url namespace="/sy" action="tagAction" var="test3"></s:url>
	//获取当前网址
	<s:property value="#test3"/>
	//使用a标签跳转到当前网址
	<a href='<s:property value="#test3"/>'>地址</a>
	//使用s标签跳转到当前网址
	<s:a href="%{#test3}">地址</s:a>
//这是xml里的配置
<package name="sy" extends="base" namespace="/sy">
		<action name="tagAction" class="com.zking.one.web.TagAction">
			<result name="success">/index.jsp</result>
		</action>
</package>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/li_2580/article/details/83995795