struts2中jsp页面传值到action方式总结(2)
- UID
- 1066743
|
struts2中jsp页面传值到action方式总结(2)
方式二 jsp中a标签url传值username,password, action中set方法接收
<a href="getIp/login?username=123&password=123">点击传值</a>
其它部分与方式一一样
完整jsp页面代码
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>login page</title>
</head>
<body>
<form action="getIp/login" method="post" name="form1">
用户名:
<s:textfield name="username" />
<br />
密 码:
<s:password name="password" />
<br />
<s:submit value="提交" />
</form>
<a href="getIp/login?username=123&password=123">点击传值</a>
</body>
</html> |
|
|
|
|
|