struts2里,ajax执行java方法,怎么得到request
dwr实现ajax
getTypeList()方法供ajax调用,可是得不到request,执行时页面上就弹出一个alert,上面只显示ERROR
要怎么得到request
Java code:
public class FileUploadAction extends ActionSupport {
public HttpServletRequest request;
public String dburl;
public List getTypeList() {
System.out.println(1);//这句能打印,然后就啥都没了
request = ServletActionContext.getRequest();//走到这就停了
System.out.println(2);
dburl = request.getSession().getServletContext().getRealPath("/");
return null;
}
}
return 要返回的list
PrintWrite pw=response.getWrite();
pw.write("需返回的数据")
和返回啥没关系,没走到return
/** 在dwr中取session,request,response */
WebContext webContext = WebContextFactory.get();
HttpSession session = webContext.getSession();
HttpServletRequest request=webContext.getHttpServletRequest();
HttpServletResponse response=webContext.getHttpServletResponse();
相关问答:
按钮放在UpdatePanel1,想通过点击调用DictionaryTvAdd.aspx弹出一个子窗体
用下面的语句提示我缺少对象
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.R ......
我JSP的页面是:
<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......
要求是输入一个数字,然后按照下面的方式输出(顺时针旋转)
比如 输入 2
则输出为
1 2 3
8 9 4
7 6 5
输入 6
则输出为
1 2 3 4 5 6
20 21 22 23 24 7
19 32 33 34 25 8
18 31 36 ......
我在一个html中写如下代码:
JScript code:
<html>
<head>
<script type="text/javascript" charset="utf-8"
src="script/jquery-1.3.2.min ......
我在 java核心技术上 看了一个 利用 Java socket email的例子 可是怎么也 不成功 为什么?
源码
Java code:
package cn.com.test.email;
import java.awt.GridBagLayout;
import java.awt.event.Action ......