怎么在Struts2.0 中响应Ajax请求

2025-01-31 18:36:21
推荐回答(1个)
回答1:

action代码:
[java] view plain copy
private InputStream inputStream;
public InputStream getResult()
{
return inputStream;
}
public String checkusername()
{
try
{
inputStream = new ByteArrayInputStream("要返回的字符串".getBytes("UTF-8"));
}
catch (UnsupportedEncodingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return "isExist";
}
struts.xml代码:

[html] view plain copy



text/html

result