关于struts-jquey-plugin中<sj:submit/>和<s:form/>的使用

(一).FormSubmission.jsp页面:

<?xml version="1.0" encoding="utf-8"?>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Form 的使用</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="styles/layout.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/showcase.js"></script>
   <sj:head
   		locale="zh_CN"
    	loadAtOnce="true"
    	compressed="false"
    	jquerytheme="showcase"
    	customBasepath="themes"
    	loadFromGoogle="false"
    	debug="true"
    />
</head>
	<body>
		<strong>显示结果的DIV</strong>
	<div id="formResult" class="result ui-widget-content ui-corner-all"></div>
    
    <s:form id="form" action="echo" theme="simple" cssClass="yform">
        <fieldset>
            <legend>AJAX Form</legend>
	        <div class="type-text">
	            <label for="echo">Echo: </label>
	            <s:textfield id="echo" name="echo" value="Hello World!!!"/>
	        </div>
	        <div>
	            <sj:submit 
	            	id="formSubmit1"
	            	targets="formResult" 
	            	value="AJAX Submit" 
	            	indicator="indicator"
	            	button="true"
	            	/>

<!--内部定义了一个url和submit-->
 <s:url id="simpleecho" value="simpleEcho"/>
	            <sj:submit 
	            	id="formSubmit2"
	            	href="%{simpleecho}" 
	            	targets="formResult" 
	            	value="AJAX Submit 2" 
	            	indicator="indicator"
	            	button="true"
	            	/>
	        </div>
        </fieldset>
    </s:form>

    <img id="indicator" src="images/indicator.gif" alt="Loading..." style="display:none"/>    
    
	<div class="code ui-widget-content ui-corner-all">
	</body>
</html>

 (二)1.echo Action的写法:

package com.anchorajax;

import com.opensymphony.xwork2.ActionSupport;

public class Echo extends ActionSupport
{
    private String echo;
    private boolean escape = true;

    public boolean isEscape() {
        return escape;
    }

    public void setEscape(boolean escape) {
        this.escape = escape;
    }

    public String getEcho() {
        return echo;
    }

    public void setEcho(String echo) {
        this.echo = echo;
    }

    public String execute() throws Exception {

        return SUCCESS;
    }
}

 2.simpleEcho的Action写法:

package com.anchorajax;

import com.opensymphony.xwork2.ActionSupport;

public class SimpleEcho extends ActionSupport
{
    private String echo;
    private boolean escape = true;

    public boolean isEscape() {
        return escape;
    }

    public void setEscape(boolean escape) {
        this.escape = escape;
    }

    public String getEcho() {
        return echo;
    }

    public void setEcho(String echo) {
        this.echo = echo;
    }

    public String execute() throws Exception {

        return SUCCESS;
    }
}

 (三)struts.xml的配置:

 <!-- echoAction --> 		
   		<action name="echo" class="com.anchorajax.Echo">
   			<result name="success">/echo.jsp</result>
   		</action>
   		
   		<!-- SimpleEchoAction --> 	
   		<action name="simpleEcho" class="com.anchorajax.SimpleEcho">
   			<result name="success">/SimpleEcho.jsp</result>
   		</action>

 (四)1.echo.jsp页面:

<%@ taglib prefix="s" uri="/struts-tags"%>
<p>Echo : <s:property value="echo" escape="%{escape}"/></p>

      2.SimpleEcho.jsp页面:

<%@ taglib prefix="s" uri="/struts-tags"%>
<s:property value="echo" escape="%{escape}"/>

 (五)显示界面:


 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值