我有<div>
标记:
<div id="content">
<jsp:include page="some.jsp"/>
</div>
我也有几个按钮:
<input type="submit" name="btn1" value="Page1">
<input type="submit" name="btn2" value="Page2">
点击btn2时点击btn1 some.jsp更改为page1.jsp和page2.jsp,我需要。
答案 0 :(得分:2)
使用动态包含,
<jsp:include page="<%= myVariable %>" flush="true" />
Pd:看看同花顺http://www.coderanch.com/t/484149/JSP/java/flush-true-jsp-include-tag。
答案 1 :(得分:1)
1-而不是使用静态包含,您可以使用动态包含,然后您可以执行以下操作:
<jsp:include page="${somePage}" flush="true" />
2-使用javascript根据您点击的按钮更改表单的操作:
<input type="submit" value="Page1" name="btn1"
onclick="document.forms[0].action = 'somePage.jsp'; return true;" />
答案 2 :(得分:0)
我正在使用这个解决方案:我的表格是:
<FORM>
<select name="choix">
<option value="choix 1">choix 1</option>
<option value="choix 2">choix 2</option>
<option value="choix 3">choix 3</option>
</select>
<input type="submit" />
</FORM>
并且我在同一个jsp页面中使用它来包含我在该表单中选择的页面:
<%
Ch = request.getParameter("choix");
%>
<div id="inculde_page">
<jsp:include page="<%= "layouts/" + Ch + ".jsp" %>" />
</div>