我想隐藏 strut2 url....我正在访问 ip:port/contextRoot/HideUrl.jsp。在这个 Jsp 中有一个按钮,点击这个 step1 动作类的功能正在调用,并且 url 更改为 ip:port/contextRoot/step1Struts2 ....我可以保留原始 url ip:port/contextRoot/HideUrl.jsp。 .....我不想在 url 中显示 'step1Struts2' ......我能做到这一点吗?如何实现?
隐藏网址.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script type="text/javascript">
function callStep1()
{
document.struts2Form.action="step1Struts2";
document.struts2Form.submit();
}
</script>
</head>
<body>
<s:form name="struts2Form">
<input type="button" value="CallStep1" onclick="callStep1()"></input>
</s:form>
</body>
</html>
struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="struts2" extends="struts-default" namespace="/">
<action name="*Struts2" class="example.HideUrl" method="{1}">
<result name="input">HideUrl.jsp</result>
</action>
</package>
<constant name="struts.action.excludePattern" value="/*.servlet"/>
</struts>
HideUrl.java
package example;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;
public class HideUrl extends ActionSupport {
public String step1() throws Exception
{
Map session = (Map)ActionContext.getContext().getSession();
System.out.print("[HideUrl] step1 ");
session.put("step1", "step1");
return "input";
}
}