When JSP jump parameter passing process parameter is null

Copyright: [Beijing] Java Youth: 456588754 https://blog.csdn.net/Amen_Wu/article/details/53457545

The following is the JSP page:

<a href="index.jsp?tid=<%=ntidSS %>&page_no=<%=nextPage%>">下一页&nbsp;&nbsp;</a>

Once tid is empty (null), click on "Next", url address would become:

http://localhost:8080/xxx/index.jsp?tid=null&page_no=2;

Since tid as JSP URL parameter value of the page pass, so request.getParameter ( "tid") of the string value is "null", the business logic code spread java tid value is no longer null, but a string "null", will lead to follow-up operational errors.

It should be treated early in the JSP page is empty, then null if no longer tid parameter passed to the request, this problem is avoided, while the value is still null.
as follows:

<a href="index.jsp?<%if(ntidS!=null){ %>tid=<%=ntidS %>&<%} %>page_no=<%=nextPage%>">下一页&nbsp;&nbsp;</a>

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/Amen_Wu/article/details/53457545