![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
struts2中用ajax标签出错。。
今天刚学struts2使用ajax标签就遇到问题,正如标题写的,我在jsp页面的<head></head>之间插入<s:headtheme="ajax"/>这句话,打开页...
今天刚学struts2使用ajax标签就遇到问题,正如标题写的,我在jsp页面的<head></head>之间插入<s:head theme="ajax"/>这句话,打开页面弹个对话框提示站点无法访问,如果把<s:head theme="ajax"/>这句取消了,才能打开页面,但这页面也失去ajax功能了。至于环境的配置应该都没问题呀,有没高手解释下原因....我把页面部分关键代码粘贴在下面了。。
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<s:head theme="ajax"/> <------加了这句就打不开页面
</head>
<body>
<s:form action="register" theme="ajax" validate="true">
<s:textfield label="用户名" name="username"></s:textfield>
<s:password label="密码" name="password"></s:password>
<s:password label="重新输入密码" name="repassword"></s:password>
<s:textfield label="年龄" name="age"></s:textfield>
<s:textfield label="生日" name="birthday"></s:textfield>
<s:submit value="发布"></s:submit>
</s:form>
<s:property value="result"/>
</body>
</html> 展开
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<s:head theme="ajax"/> <------加了这句就打不开页面
</head>
<body>
<s:form action="register" theme="ajax" validate="true">
<s:textfield label="用户名" name="username"></s:textfield>
<s:password label="密码" name="password"></s:password>
<s:password label="重新输入密码" name="repassword"></s:password>
<s:textfield label="年龄" name="age"></s:textfield>
<s:textfield label="生日" name="birthday"></s:textfield>
<s:submit value="发布"></s:submit>
</s:form>
<s:property value="result"/>
</body>
</html> 展开
展开全部
如果你的Struts版本是2.1.6以上的,那就要加struts2-dojo-plugin-2.1.6.jar,Struts2升级以后把Ajax单独提出来放这个里面了。
像我用的就是struts2.1.8,加了struts2-dojo-plugin-2.1.8.jar后,
页面改成:
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sd" uri="/struts-dojo-tags"%>
<s:head />
<sd:parseContent="true"/>
像我用的就是struts2.1.8,加了struts2-dojo-plugin-2.1.8.jar后,
页面改成:
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sd" uri="/struts-dojo-tags"%>
<s:head />
<sd:parseContent="true"/>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询