JavaScript中怎么向Action类传值
functionaddbook(){varB_ID=$("#B_Name").val();varAuthor=$("#Author").val();varPublishe...
function addbook(){
var B_ID = $("#B_Name").val();
var Author = $("#Author").val();
var Publisher = $("#Publisher").val();
var Publi_Date = $("#Publi_Date").val();
var B_State=$("#B_State").val();
var B_Type=$("#B_Type").val();
alert(B_ID+Author+Publisher+Publi_Date+B_State+B_Type);
$.get("bookmanager_addBook.action",
{B_ID:B_ID , B_Name:B_Name , Author:Author ,Pulisher:Publisher, Publi_Date:Publi_Date,B_State:B_State,B_Type:B_Type},
function(data)
{alert(data);
$("#B_ID").val('');
$("B_Name").val('');
$("#Author").val('');
$("#Publisher").val('');
$("#Publi_Date").val('');
$("#B_State").val('在馆');
$("#B_Type").val('');
});
}
或者是Action类addbook方法获取值有问题?
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
long B_ID = Integer.parseInt(request.getParameter("B_ID"));
String B_Name = request.getParameter("B_Name");
String Author = request.getParameter("Author");
String Publisher = request.getParameter("Publisher");
String Publi_Date = request.getParameter( "Publi_Date");
String B_State = request.getParameter("B_State");
String B_Type = request.getParameter("B_Type");
反正没从JS里取到值,在Action类中request.getParameter("B_ID");就没有执行
求高人指点,会追加分,THANK
JS函数已经取到 JSP页面的值了,就是不知道怎么传到ACTION类 展开
var B_ID = $("#B_Name").val();
var Author = $("#Author").val();
var Publisher = $("#Publisher").val();
var Publi_Date = $("#Publi_Date").val();
var B_State=$("#B_State").val();
var B_Type=$("#B_Type").val();
alert(B_ID+Author+Publisher+Publi_Date+B_State+B_Type);
$.get("bookmanager_addBook.action",
{B_ID:B_ID , B_Name:B_Name , Author:Author ,Pulisher:Publisher, Publi_Date:Publi_Date,B_State:B_State,B_Type:B_Type},
function(data)
{alert(data);
$("#B_ID").val('');
$("B_Name").val('');
$("#Author").val('');
$("#Publisher").val('');
$("#Publi_Date").val('');
$("#B_State").val('在馆');
$("#B_Type").val('');
});
}
或者是Action类addbook方法获取值有问题?
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
long B_ID = Integer.parseInt(request.getParameter("B_ID"));
String B_Name = request.getParameter("B_Name");
String Author = request.getParameter("Author");
String Publisher = request.getParameter("Publisher");
String Publi_Date = request.getParameter( "Publi_Date");
String B_State = request.getParameter("B_State");
String B_Type = request.getParameter("B_Type");
反正没从JS里取到值,在Action类中request.getParameter("B_ID");就没有执行
求高人指点,会追加分,THANK
JS函数已经取到 JSP页面的值了,就是不知道怎么传到ACTION类 展开
展开全部
你在这里
$.get("bookmanager_addBook.action",
{B_ID:B_ID , B_Name:B_Name , Author:Author ,Pulisher:Publisher, Publi_Date:Publi_Date,B_State:B_State,B_Type:B_Type},
B_ID:B_ID 不能同名,
而且你jquery的js文件导入了吗?
应该写成这样:
function addbook(){
var B_ID2 = $("#B_Name").val();
var Author2 = $("#Author").val();
var Publisher2 = $("#Publisher").val();
var Publi_Date2 = $("#Publi_Date").val();
var B_State2=$("#B_State").val();
var B_Type2=$("#B_Type").val();
alert(B_ID2+Author2+Publisher2+Publi_Date2+B_State2+B_Type2);
$.get("bookmanager_addBook.action",
{B_ID:B_ID2 , B_Name:B_Name2 , Author:Author2 ,Pulisher:Publisher2, Publi_Date:Publi_Date2,B_State:B_State2,B_Type:B_Type2},
function(data)
{alert(data);
$("#B_ID").val('');
$("B_Name").val('');
$("#Author").val('');
$("#Publisher").val('');
$("#Publi_Date").val('');
$("#B_State").val('在馆');
$("#B_Type").val('');
});
}
或者是Action类addbook方法获取值有问题?
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
String B_ID = request.getParameter("B_ID");
String B_Name = request.getParameter("B_Name");
String Author = request.getParameter("Author");
String Publisher = request.getParameter("Publisher");
String Publi_Date = request.getParameter( "Publi_Date");
String B_State = request.getParameter("B_State");
String B_Type = request.getParameter("B_Type");
$.get("bookmanager_addBook.action",
{B_ID:B_ID , B_Name:B_Name , Author:Author ,Pulisher:Publisher, Publi_Date:Publi_Date,B_State:B_State,B_Type:B_Type},
B_ID:B_ID 不能同名,
而且你jquery的js文件导入了吗?
应该写成这样:
function addbook(){
var B_ID2 = $("#B_Name").val();
var Author2 = $("#Author").val();
var Publisher2 = $("#Publisher").val();
var Publi_Date2 = $("#Publi_Date").val();
var B_State2=$("#B_State").val();
var B_Type2=$("#B_Type").val();
alert(B_ID2+Author2+Publisher2+Publi_Date2+B_State2+B_Type2);
$.get("bookmanager_addBook.action",
{B_ID:B_ID2 , B_Name:B_Name2 , Author:Author2 ,Pulisher:Publisher2, Publi_Date:Publi_Date2,B_State:B_State2,B_Type:B_Type2},
function(data)
{alert(data);
$("#B_ID").val('');
$("B_Name").val('');
$("#Author").val('');
$("#Publisher").val('');
$("#Publi_Date").val('');
$("#B_State").val('在馆');
$("#B_Type").val('');
});
}
或者是Action类addbook方法获取值有问题?
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
String B_ID = request.getParameter("B_ID");
String B_Name = request.getParameter("B_Name");
String Author = request.getParameter("Author");
String Publisher = request.getParameter("Publisher");
String Publi_Date = request.getParameter( "Publi_Date");
String B_State = request.getParameter("B_State");
String B_Type = request.getParameter("B_Type");
展开全部
用的struts1还是struts2
?
?
更多追问追答
追问
Struts2
追答
既然struts2就不要request.getParameter()了。传过去的参数叫什么名字,在action里就给相应的属性名,给上get/set
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我现在有一个问题,就是将form中的action设为JavaScript代码,那传递的参数值留几个hidden的隐藏域 打开的窗口里调用parent把值设置回来咯
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$.get("bookmanager_addBook.action?Name=“+B_ID",
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询