我有由下列文件的一个Struts2的Web应用程序:如何通过Ajax来发送请求参数Struts2的action类
member.jsp
:
<script type="text/javascript">
String str1 = "aaa";
String str2 = "bbb";
xmlhttp.open("GET", "http://localhost:8080/project/editprofile.action", true);
xmlhttp.send(null);
</script>
struts.xml
:
<action name="editprofile" method="editProfile" class="controller.ControllerSln">
<result name="success" type="stream">
<param name="contentType">text/html</param>
<param name="inputName">inputStream</param>
</result>
</action>
ControllerSln.java
:
public String editProfile() throws UnsupportedEncodingException {
return SUCCESS;
}
我想通过Ajax将字符串“aaa”和“bbb”发送到controller.ControllerSln#editProfile()
方法。我怎样才能实现它?
我不是你nderstand。为什么不能在请求中将它们作为参数传递? –
这是我的第一个Web项目,我的信息是基本的,我在网上搜索过,但我无法理解,并将它们应用于我的项目,所以我在这里问过。 – selentoptas
但我还是不明白。 –