java代码:
package Test.Action.UserAction;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class UserAction extends ActionSupport{
public UserAction(){
}
public String execute(){
return SUCCESS;
}
}
---------------------------------------------------------------------------------------------------------
struts.xml代码:
<constant name="struts.devMode" value="true" />
<package name="user" namespace="/" extends="struts-default">
<action name="user" class="Test.Action.UserAction.UserAction">
<result>/welcome.jsp</result>
</action>
</package>
---------------------------------------------------------------------------------------------------------
jsp代码:
<script type="text/javascript">
function userFunction(){
window.location.href="http://localhost:8080/Test/user";
}
</script>
body中的代码:
页面跳转方法<br>
form表单提交<br>
<form name="f" action="" method="post">
<input type="button" value="button"
οnclick="javascript:document.f.action='user';javascript:document.f.submit();"/>
</form>
<hr>
from表单和javascript混合版(注意,第一种和第二种有冲突,只能同时使用其一)<br>
<form name="f" action="user" method="post">
<input type="submit" >
</form>
<hr>
javascript方法:<br>
<input type="button" value="button2" οnclick="userFunction()"><br/>
<hr>
超链接<br>
<a href="http://localhost:8080/Test/user">user页面1</a>
<hr/>
超链接(内含java代码)<br>
<a href="<%=basePath%>user">user页面2</a>
<hr>
超链接(最简洁)<br/>
<a href="user">user页面3</a>
<hr/>
超链接(javascript)<br>
<a href="javascript:void(0)" οnclick="userFunction()">user页面4</a>
<hr>
超链接(javascript2)<br>
<a href="javascript:userFunction()">user页面5</a><br>
<hr>
超链接(EL表达式)<br>
<a href="${pageContext.request.contextPath}/user">user页面6</a><br>
<hr>
<s:debug></s:debug>
package Test.Action.UserAction;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class UserAction extends ActionSupport{
public UserAction(){
}
public String execute(){
return SUCCESS;
}
}
---------------------------------------------------------------------------------------------------------
struts.xml代码:
<constant name="struts.devMode" value="true" />
<package name="user" namespace="/" extends="struts-default">
<action name="user" class="Test.Action.UserAction.UserAction">
<result>/welcome.jsp</result>
</action>
</package>
---------------------------------------------------------------------------------------------------------
jsp代码:
<script type="text/javascript">
function userFunction(){
window.location.href="http://localhost:8080/Test/user";
}
</script>
body中的代码:
页面跳转方法<br>
form表单提交<br>
<form name="f" action="" method="post">
<input type="button" value="button"
οnclick="javascript:document.f.action='user';javascript:document.f.submit();"/>
</form>
<hr>
from表单和javascript混合版(注意,第一种和第二种有冲突,只能同时使用其一)<br>
<form name="f" action="user" method="post">
<input type="submit" >
</form>
<hr>
javascript方法:<br>
<input type="button" value="button2" οnclick="userFunction()"><br/>
<hr>
超链接<br>
<a href="http://localhost:8080/Test/user">user页面1</a>
<hr/>
超链接(内含java代码)<br>
<a href="<%=basePath%>user">user页面2</a>
<hr>
超链接(最简洁)<br/>
<a href="user">user页面3</a>
<hr/>
超链接(javascript)<br>
<a href="javascript:void(0)" οnclick="userFunction()">user页面4</a>
<hr>
超链接(javascript2)<br>
<a href="javascript:userFunction()">user页面5</a><br>
<hr>
超链接(EL表达式)<br>
<a href="${pageContext.request.contextPath}/user">user页面6</a><br>
<hr>
<s:debug></s:debug>
---------------------------------------------------------------------------------------------------------
welcome.jsp是被跳转页面我就不用写了。