jsp修改员工资料页面无法用jquery抓到节点

u011010971 2013-07-25 03:36:40
本菜用struts2框架开发网站,其中一个模块是公司员工可以修改个人资料,步骤如下:
在员工列表添加了修改链接,动作指向gomodify.action?id=${id}
由一个Action java类处理,代码如下:


package com.jumbo.action;

import com.jumbo.dao.JumboAddDAO;
import com.jumbo.dao.impl.JumboAddDAOImpl;
import com.jumbo.entity.JumboTeam;

public class GoModifyTeamAction {
//input
private int id;
//output
private JumboTeam user;

public String execute() throws Exception{
JumboAddDAO dao=new JumboAddDAOImpl();
user=dao.getUserById(id);
return "success";
}

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public JumboTeam getUser() {
return user;
}
public void setUser(JumboTeam user) {
this.user = user;
}

}

响应回一个对象“user”,以供下一个页面modifyteam.jsp,响应回的user是为了显示当前修改的资料是哪个人的,页面代码如下:


<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>员工资料修改</title>
<link href="../css/login.css" rel="stylesheet" type="text/css" />
<link href="../css/page_bottom.css" rel="stylesheet" type="text/css" />

<style type="text/css">
#ortd span{
font-weight: bolder;
}
table tr td{
border:2px solid green;
}
</style>

<script type="text/javascript" src="../js/jquery-1.4.3.js"></script>
<script type="text/javascript">
$(function(){
$('#mname').blur(function(){
alert('失去焦点');
});
});

</script>
</head>
<body>
<center><h2>修改员工资料</h2></center>
<table style="width: 76%">
<thead>
<tr style="font-weight: bolder;">
<td style="width: 380px">原始资料</td>
<td>修改部分</td>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;" id="ortd">
<span>id:</span>    ${user.id}<br/>
<span>姓名:</span>    ${user.name}<br/>
<span>昵称:</span>    ${user.nickname}<br/>
<span>职位:</span>    ${user.position}<br/>
<span>简介:</span><br />
    ${user.describ}<br/>
<span>照片:</span><br/>
<img style="width: 190px;height: 190px" src="teamimages/${user.pic}" />
</td>

<td>
<form action="">
修改姓名:  <input id="mname" type="text" />
</form>
</td>
</tr>
</tbody>
</table>
</body>
</html>

问题:
左侧可以正常的显示当前员工资料,在编写右侧修改资料表单时试图用jquery进行表单验证,但无论如何都无法找到节点元素,考虑到可能是由于action响应回数据的原因造成,故进行以下实验: 直接在地址栏中输入页面的
url:http://localhost:8080/testadmin/update/modifyteam.jsp
发现可以使用jquery抓取节点并出现alert提示框,请问这种情况应该如何处理,多谢多谢。
...全文
138 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tony4geek 2013-07-25
  • 打赏
  • 举报
回复
你的action 没继承struts2 的类?
u011010971 2013-07-25
  • 打赏
  • 举报
回复
自己顶一下,还在不断试验当中

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧