<sx:submit targets="div2";/>在 struts 2 中不起作用 [英] <sx:submit targets="div2" /> is not working in struts 2

查看:21
本文介绍了<sx:submit targets="div2";/>在 struts 2 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 struts 2 框架开发 ajax.应用程序有两个文本框姓名"和年龄".在提交时,这两个值应该使用同一页面上的 div 标签更新.

I am working on ajax using struts 2 frame work. Application has two text boxes "name" and "age". On submitting , those two values should be updated using div tag on the same page itself.

<sx:div id="div2" executeScripts="true" theme="ajax">Value</sx:div>


<sx:submit targets="div2"  value="submit">

当我在 sx:submit 中使用targets"属性时,出现一些异常.当我删除目标"时,没有抛出异常.但是应用程序需要目标"属性来更新 div 标签.我需要处理异常吗?我正在尝试将此作为示例,我的应用程序需要这种功能.帮我.

when i use "targets" attribute in sx:submit ,getting some exception. when i remove "targets" no exception has been thrown.But application needs "targets" attribute to update the div tag.Do i need to any handle exception ? I am trying this as a sample exmple , my application needs this kind of functionality. Help me.

源代码如下:

<%@taglib  uri="/struts-tags"  prefix="s"  %>

<%@taglib uri="/struts-dojo-tags" prefix="sx" %>

<html>

<head><title>Ajax_Div_Tag_Example</title>

</head>

<body><h1>Ajax_Div_Tag_Example</h1><hr>

<sx:div id="div2" executeScripts="true" theme="ajax">Value</sx:div>

<s:form action="resultAction">

<s:textfield name="name" label="Name"></s:textfield>

<s:textfield name="age" label="Age"></s:textfield>

<sx:submit value="submit" targets="div2"> </sx:submit>

</s:form>

</body>

</html> 

struts.xml

struts.xml

<action  name="resultAction"  class="ActionClasses.AjaxDivAction">
        <result name="success">/resultPage.jsp</result>
        </action>

resultPage.jsp

resultPage.jsp

<%@taglib  uri="/struts-tags"  prefix="s"  %>

<html>

<head><title>Ajax_Div_Tag_Example</title>

</head>

<body><hr>Name : <s:property value="name"/><br>

Age : <s:property value="age"/><hr>

</body>

</html> 

AjaxDivAction.java

AjaxDivAction.java

package ActionClasses;
import  com.opensymphony.xwork2.ActionSupport;

public class AjaxDivAction extends ActionSupport{

/**
     * 
     */
    private static final long serialVersionUID = 1L;

private String name;

private String age;

public String getAge() {

return age;

}

public void setAge(String age) {

this.age = age;

}

public String getName() {

return name;

}

抛出的异常如下

org.apache.jasper.JasperException: An exception occurred processing JSP page /AjaxDemo.jsp at line 21

18: 
19: <s:textfield name="age" label="Age"></s:textfield>
20: 
21: <sx:submit value="submit" targets="div2"> </sx:submit>
22: 
23: </s:form>
24: 


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)

root cause

javax.servlet.ServletException: java.lang.AbstractMethodError
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
    org.apache.jsp.AjaxDemo_jsp._jspService(AjaxDemo_jsp.java:94)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)

root cause

java.lang.AbstractMethodError
    org.apache.struts2.components.ClosingUIBean.start(ClosingUIBean.java:65)
    org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:53)
    org.apache.jsp.AjaxDemo_jsp._jspx_meth_sx_005fsubmit_005f0(AjaxDemo_jsp.java:242)
    org.apache.jsp.AjaxDemo_jsp._jspx_meth_s_005fform_005f0(AjaxDemo_jsp.java:168)
    org.apache.jsp.AjaxDemo_jsp._jspService(AjaxDemo_jsp.java:82)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.

谢谢

贾根

推荐答案

strut2-core-2.jar 文件有问题.我下载了最新版本并尝试了,现在工作正常.

There was a problem with strut2-core-2.jar file.I downloaded latest version and tried.It is working fine now.

这篇关于&lt;sx:submit targets="div2";/&gt;在 struts 2 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆