struts2.1中使用Ajax主题
来源:互联网 发布:婴幼儿棉裤淘宝 编辑:程序博客网 时间:2024/06/05 06:15
1.将struts2-dojo-plugin-2.1.8.1.jar加入lib中
2.在需要使用标签的jsp文件里写上<%@taglib prefix="sx" uri="/struts-dojo-tags" %>
3.在<head>标签里写上<sx:head/>
之后我们就可以开始使用struts2的ajax标签了
1、需引入struts2-dojo-plugin-2.1.8.1.jar
2、页面标签的变化如下:
ajax.jsp
Java代码
<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib prefix="sx" uri="/struts-dojo-tags"%><!-- 注意 --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <title>Ajax Demo</title><sx:head/><!-- 注意 --></head><body> <h1>Ajax Dmeo:</h1><div id="show">一个div</div><s:form namespace="/demo" action="ajax!testAjax" method="post"><!-- 注意 --><s:textfield name="name"></s:textfield><sx:submit value="修改上面div的值" targets="show"></sx:submit><!-- 注意 --></s:form></body></html>Java代码
package cn.ibeans.demo.web.action;import org.apache.log4j.Logger;import org.apache.struts2.convention.annotation.Namespace;import org.apache.struts2.convention.annotation.Result;import org.apache.struts2.convention.annotation.Results;import com.opensymphony.xwork2.ActionSupport;@Namespace("/demo")@Results({@Result(name="ok",location="ajaxResult.jsp")})public class AjaxAction extends ActionSupport {private static Logger log= Logger.getLogger(AjaxAction.class);private String data;public String getData() {return "服务器的返回值:"+data;}public void setData(String data) {this.data = data;}public String testAjax() throws Exception{log.info("ajax 调用成功!");return "ok";}@Overridepublic String execute() throws Exception {log.info("ajax 调用成功!");return super.SUCCESS;}}ajaxResult.jsp:
Java代码
<%@ taglib prefix="s" uri="/struts-tags" %><%request.setAttribute("decorator", "none");response.setHeader("Cache-Control","no-cache"); //HTTP 1.1response.setHeader("Pragma","no-cache"); //HTTP 1.0response.setDateHeader ("Expires", 0); //prevents caching at the proxy serverSystem.out.println("ajaxResult.jsp is called");%>Result: <s:property value="data"/><br/>
- struts2.1中使用Ajax主题
- struts2中使用AJAX
- struts2中使用ajax
- struts2中使用ajax
- struts2中使用ajax
- struts2中如何使用主题theme
- struts2 action中使用AJAX
- struts2中使用ajax之一
- struts2中ajax的使用
- struts2中ajax的使用
- struts2中ajax的使用
- 在JSP页面中使用Ajax主题时的引入
- 在Struts2中使用JSON AJAX
- struts2中使用ajax之二
- 在Struts2中使用JSON AJAX
- struts2中使用ajax请求验证表单
- s:datetimepicker标签如何才能使用(struts2如何结合ajax主题)
- strut2中使用ajax主题时出现 template/ajax/head.ftl. 错误的解决办法
- ERROR 1130: Host 192.168.88.160 is not allowed to connect to this MySQL server
- linux内核hlist分析
- 习题3-5,旋转
- php的引用(在变量或者函数、对象等前面加上&符号)
- HDU 3038 How Many Answers Are Wrong
- struts2.1中使用Ajax主题
- 程序的执行过程
- 转载: Visual Studio Unit Test
- UVA 10391 - Compound Words
- WPF数据验证(3)——自定义验证规则
- 习题3-6,进制转换1
- sleep()【延迟代码执行】
- Linux下scp的用法
- 习题3-7,进制转换2