关于struts-jquey-plugin中的使用

(一).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}"/>

 (五)显示界面:


关于struts-jquey-plugin中<sj:submit/>和<s:form/>的使用_第1张图片

 


你可能感兴趣的:(struts)