struts2中用ajax标签出错。。

来源:百度知道 编辑:UC知道 时间:2024/05/27 17:46:03
今天刚学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

如果你的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"/>