jsp code:
<a href="<%= request.getContextPath()%>/DiaryListServlet" title="日记" target="mainFrame" class="diary" onclick="<%request.setAttribute("type","diary"); %>"><font class="dropmenu_text">日记</font> </a>
Luzhu Are you in the wrong place? ? ? ? ? I haven’t done Java for a long time. I suggest you splice it directly behind your href, and then use request.getParameter(key) in the servelt to get the value. Which onclick do you use like this? This should trigger an event, right? ? ? ? ? Instead of assigning values to the attributes in your request
use the & symbol to link it!
The sentence you wrote, onclick="<%request.setAttribute("type","diary"); %>", whether you click it or not, the jsp will be executed during compilation. Even if there is no problem, you still need to pay attention to the quotation marks. .
<%request.setAttribute('type','diary'); %>Try again like this, but this does not mean that it is the result after you click.
Dear, you can’t play like this. In jsp, java is always compiled first. Do you think it is feasible to convert your code into js form? Generally, when written this way, the encapsulated data processed by the action is sent to the page, and then displayed during loading, right? If you want onclick to pass a value, then you have to construct a click function in the form of js, and splice your parameters on the href