Based on the use of jsp:included and jsp:param messy code solution
- 2020-06-07 05:09:00
- OfStack
If the page page in jsp:include is cluttered, you need to use it again
<
jsp:include page=""
>
On the page of
<
body
>
After add
< %
request. setCharacterEncoding (' UTF - 8 "); // or specified code (GBK or others)
% >
As shown below:
< %
request. setCharacterEncoding (' UTF - 8 "); // or specified code (GBK or others)
% >
As shown below:
jsp-include.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<html>
<head><title>jsp include Test page </title></head>
<body>
<%
request.setCharacterEncoding("UTF-8") ;
%>
<h3>jsp include Instructions to test </h3>
<jsp:include page="forward-result.jsp">
<jsp:param name="age" value="32" />
<jsp:param name="username" value=" zhang 3" />
</jsp:include>
</body>
</html>
forward-result.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<html>
<head><title>forward The results page </title></head>
<body>
Age: <%=request.getParameter("age")%><br />
Name: <%=request.getParameter("username") +"--11"%>
</body>
</html>