(我从Google搜索获得了源代码。我自己输入了一些代码来学习。我进行了三遍检查,键入的代码与源代码相同。我什至复制并粘贴了它,但仍然遇到相同的错误。)<% UserBean currentUser = (UserBean (session.getAttribute("currentSessionUser"));%>在JSP文件中,这里出现语法错误。我附上了其详细信息的屏幕截图。我之前制作了Userbean.java和setAttribute“ currentSessionUser”。这是该JSP页面的完整代码。 (html标记未出现在代码中,因此我添加了屏幕截图。(次要问题)是否可以在此处显示html标记? 似乎在这里不起作用。)  谁能猜出我为什么会出现语法错误?我试过了<% UserBean currentUser = (UserBean (session.getAttribute("currentSessionUser")));%> //three closing brackets <% UserBean currentUser = UserBean (session.getAttribute("currentSessionUser"));%> //removing the bracket in front of UserBean (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 <% UserBean currentUser = (UserBean (session.getAttribute("currentSessionUser"));%>只需计算左右括号的数量即可。但是您想做的是cast所以UserBean currentUser = (UserBean) (session.getAttribute("currentSessionUser"));顺便说一句,也许最好在JSP中使用EL,而不是Java (adsbygoogle = window.adsbygoogle || []).push({});
09-26 05:47