问题描述
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <head> <title>主界面</title><link rel="stylesheet" type="text/css" href="jquery-easyui-1.2.4/themes/default/easyui.css"><link rel="stylesheet" type="text/css" href="jquery-easyui-1.2.4/themes/icon.css"><link rel="stylesheet" type="text/css" href="jquery-easyui-1.2.4/demo/demo.css"><script type="text/javascript" src="jquery-easyui-1.2.4/jquery-1.6.min.js"></script><script type="text/javascript" src="jquery-easyui-1.2.4/jquery.easyui.min.js"></script><script type="text/javascript" src="jquery-easyui-1.2.4/locale/easyui-lang-zh_CN.js"></script><script type="text/javascript"><%@ include file="tree.js"%><%@ include file="datagrid.js"%>$(document).ready(function(){ $("#selectButton").click(function(){ clickButton(); });});function clickButton() { var url = 'select.do'; var params = { beginTime:$('#beginTime').attr('value'), endTime:$('#endTime').attr('value')//对应的是控件的Id,之前错写成了Name,一个小小的错误也是毁灭性的打击 };jQuery.post(url,params,callbackFun,'json');} function callbackFun(data)//我看网上也可以写与Result,应该是任意的,是一个Json值 {alert("SUCCESS"); }</script> </head><body class="easyui-layout"><div region="north" title="作为参数配置模块" split="true" style="height:108px;padding:6px;"><label>开始时间</label><input class="easyui-datetimebox" id="beginTime" required="true" value="2010-01-03 02:03:56" style="width:150px"></p><label>结束时间</label><input class="easyui-datetimebox" id="endTime" required="true" value="2010-01-03 02:03:56" style="width:150px"><input class="easyui-validatebox" type="text" name="name" required="true"></input><input id="selectButton" type="button" value="登陆" ></div><div region="south" title="South Title" split="true" style="height:100px;padding:10px;background:#efefef;"><div class="easyui-layout" fit="true" style="background:#ccc;"><div region="center">sub center</div><div region="east" split="true" style="width:200px;">sub center</div></div></div><div region="west" iconCls="icon-reload" title="部门树形结构" split="true" style="width:230px;"><ul id="depttree"></ul></div><div region="center" title="Main Title" style="overflow:hidden;"><div class="easyui-tabs" fit="true" border="false" ><div title="Tab1"><table id="datagrid" region="center"></table></div><div title="Tab2" closable="true" style="padding:20px;">This is Tab2 width close button.</div><div title="Tab3" iconCls="icon-reload" closable="true" style="overflow:hidden;padding:5px;"></div></div></div></body></html>package com.zheshou.action;import javax.annotation.Resource;import org.apache.struts2.convention.annotation.Action;import org.apache.struts2.convention.annotation.InterceptorRef;import org.apache.struts2.convention.annotation.InterceptorRefs;import org.apache.struts2.convention.annotation.Namespace;import org.apache.struts2.convention.annotation.ParentPackage;import org.apache.struts2.convention.annotation.Result;import org.apache.struts2.convention.annotation.Results;import org.apache.struts2.interceptor.validation.SkipValidation;import org.springframework.context.annotation.Scope;import org.springframework.stereotype.Component;import org.springframework.web.portlet.bind.annotation.ResourceMapping;import com.opensymphony.xwork2.ActionSupport;import com.opensymphony.xwork2.validator.annotations.*;import com.sun.jndi.url.corbaname.corbanameURLContextFactory;import com.zheshou.model.Employee;import com.zheshou.model.User;import com.zheshou.service.EmployeeService;@ParentPackage(value="json-default")@Namespace(value="/")public class SelectAction extends ActionSupport {//2.ActionSupport必须有这个才行.但是可以不用Execute了private String beginTime;private String endTime;private com.zheshou.model.User user;public com.zheshou.model.User getUser() {return user;}public void setUser(com.zheshou.model.User user) {this.user = user;}public String getBeginTime() {return beginTime;}public void setBeginTime(String beginTime) {this.beginTime = beginTime;}public String getEndTime() {return endTime;}public void setEndTime(String endTime) {this.endTime = endTime;}@Action(value="select",results={@Result(type="json",name="selectuser",params={"includeProperties","user.*"}//root)} ) public String execute(){System.out.println(beginTime);System.out.println(endTime);user.setId(1);user.setUsername("张三");return "selectuser";}}核心代码,如上,不知道为什么,回归函数,就是触发不了,其它的,都正常 问题补充:blueram 写道
解决方案
回调没有执行,看看是不是你的action代码不正确,后台报错了没有,使用firebug调试下
解决方案二:
你的前端代码本身没有问题,请检查,后端的输出是否正确,必须是 JSON 代码。