日期:2014-05-17 浏览次数:20697 次
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>父页面</title>
</head>
<body>
<iframe src="user.jsp" style="margin-left: 500px;" name="main"
width="500px" height="200px"></iframe>
<iframe src="test.jsp"></iframe>
<s:debug/>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>用户的页面---用来显示用户的信息</title>
</head>
<body>
这是用户的页面,在这里显示用户的信息。
<s:iterator value="users" var="user">
<s:property value="#user.userName" />
<s:property value="#user.passWord" />
</s:iterator>
<s:debug/>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<html>
<body>
这是一个用于测试的页面。
<form action="userAction_findUsers" method="post">
<input type="submit" value="提交" />
</form>
</body>
</html>
package com.xumuye.action;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.opensymphony.xwork2.ActionSupport;
import com.xumuye.bean.User;
import com.xumuye.service.UserService;
@Controller
public class UserAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = -3190817860600835920L;
// ///////////////////////////////////////////////
// 成员变量/////////////////////////////////////
// 注入UserService
@Autowired
private UserService userService;
private List<User> users;
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public String findUsers() {
users = userService.findUsers();
return "findusers";
}
}
package com.xumuye.dao.impl;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.xumuye.bean.User;
import com.xumuye.dao.UserDao;
@Repository
public class UserDaoImpl implements UserDao {
// 注入sessionFactory
@Autowired
private SessionFactory sessionFactory;
@SuppressWarnings("unchecked")
@Override
public Lis