[英]struts2-jquery datepicker tag not loading in struts2-jquery tabbedpannel tag
我有一個頁面index.jsp
,我在此jsp中使用了struts2-jquery tabbedpannel標記來顯示另外兩個JSP( first.jsp
和second.jsp
)作為選項卡。
的index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<sj:head />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Index Page</title>
</head>
<body>
<sj:tabbedpanel
id="remotetabs"
selectedTab="0"
show="true"
hide="'fade'"
collapsible="true"
sortable="true">
<sj:tab id="tab1" href="first.jsp" label="First JSP"/>
<sj:tab id="tab2" href="second.jsp" label="Second JSP"/>
</sj:tabbedpanel>
</body>
</html>
另外兩個JSP包含一個帶有struts2-datepicker標記的表單。 這是其中之一...
first.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<link rel="stylesheet" type="text/css" href="css/view.css" media="all">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>First JSP</title>
</head>
<body>
<div>
<s:form action="firstAction" >
<sj:datepicker
key="timeStamp"
name="timeStamp"
label="Time Stamp"
timepicker="true"
displayFormat="yy-mm-dd"
timepickerFormat="HH:mm"/>
<s:submit value="Submit"></s:submit>
</s:form>
</div>
</body>
</html>
問題是,第一次加載index.jsp
,first.jsp上的struts2-jquery datepicker標記工作正常,但是當我切換到第二個選項卡時; 它將在AJAX中加載second.jsp
(second.jsp包含與first.jsp相同的代碼),second.jsp上的 struts2-jquery second.jsp
標記不起作用。
現在,當我切換回“第一選項卡”以顯示first.jsp
,struts2-jquery first.jsp
標記也不起作用。 第一次加載后,它只是停止工作。
問題在於您正在調用JSP頁面,而應該調用Struts2 Actions。
Struts2是MVC。 您不是從視圖調用視圖,而是應該調用將調度到視圖的控制器。
第一次使用它是因為在first.jsp
和second.jsp
中提供struts和struts-jquery標簽的變量是從IndexAction
。
您應該改為定義FirstAction
和SecondAction
並通過href
屬性中的AJAX進行調用:
<s:url var="firstActionUrl" action="first" namespace="/" />
<sj:tab id="tab1" href="%{#firstActionUrl}" label="First JSP"/>
<s:url var="secondActionUrl" action="second" namespace="/" />
<sj:tab id="tab2" href="%{#secondActionUrl}" label="Second JSP"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.