I'm using Struts2 and I want to do an ajax post to upload a file to the server side. I have installed Struts2 JQuery Plugin, but I think it's a compatibility problem, because when I load my page, the chrome console show this problem:
<script type="text/javascript">
$(function() {
jQuery.struts2_jquery.version="3.6.0"; Uncaught TypeError: Cannot set property 'version' of undefined
I have tried other versions of plugin (3.3.0, 3.7.0), but I have the same problem. I'm using struts2-core-2.3.1.2.
My web.xml have:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
And the header of my jsp is:
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<!doctype html>
<html>
<head>
<title></title>
<script src="js/jquery.js"></script>
<script src="js/jquery-ui.js"></script>
<sj:head jqueryui="true"/>
<tiles:insertAttribute name="header" />
And my sj:submit to upload the file:
<s:url id="servicesUrl" action="ajaxCall"></s:url>
<sj:submit name="button1" value="Submit" href="%{servicesUrl}" targets="myAjaxTarget" ></sj:submit>
<div id="myAjaxTarget">
</div>
And under this part of the submit, chrome shows
Uncaught TypeError: Cannot read property 'bind' of undefined
PD: If I can complete the question, tell me and I'll do it with more information
While using this
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
No need of using
<script src="js/jquery.js"></script>
Since <sj:head/>
generates all the imports needed to run jquery
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.