0
私はjspページをAjaxコールで他のページにインクルードしようとしていました。 問題は、インクルードするページにhtml要素の間に空白があると、インクルージョンが失敗することになります。例えば(AJAX - Jsp include)AjaxにJSPを含めるには?
ここに私のデモのindex.jspである:ここで
function include() {
alert("Hello from include function.");
$.ajax({
type: "GET",
url: "Include",
success: function() {
alert("Ajax success function.");
$("#container").html("<jsp:include page='hello.jsp' />");
alert("Ajax end success function.");
}
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<button onclick="include()">Include</button>
<div id="container" style="border: 1px solid red;"></div>
</body>
は(ない要素タグの間にスペースまたはincludeは失敗します)含まれてHello.jspのページです。
<p>Hello from the included file.</p><p>Hello from the included file.</p><p>Hello from the included file.</p>
そして、サーブレットはdo-nothing(今のところ)doGetメソッドを持っています。
皆さんに同じことを浮かべていますか?私のコードに何か問題がありますか? 同じ作業を行うための他の作業方法はありますか?
申し訳ありませんが、あなたは例を挙げることができますか?ありがとう –