偶写jsp时候想用session,于是新建了个文件,写了2行如下,可报错<%@page contentType="text/html;charset=gb2312" language="java" ><%
session.setAttribute("session_name","");out.print((String)session.getAttribute(session_name));
%>可就是出错,错误提示为
Method setAttribute(java.lang.String) not found in found in interface javax.servlet.http.HttpSessionMethod getAttribute(java.lang.String) not found in found in interface javax.servlet.http.HttpSession偶配置的是 resin-2.1.9 + apacher + j2eesdk 的环境谢谢
session.setAttribute("session_name","");out.print((String)session.getAttribute(session_name));
%>可就是出错,错误提示为
Method setAttribute(java.lang.String) not found in found in interface javax.servlet.http.HttpSessionMethod getAttribute(java.lang.String) not found in found in interface javax.servlet.http.HttpSession偶配置的是 resin-2.1.9 + apacher + j2eesdk 的环境谢谢
意思是说。在这个接口里,创建不了这个方法!
是错误语句!!应该改为out.print((String)session.getAttribute("session_name"));
改成out.print((String)session.getAttribute("session_name"));试试
<%@page contentType="text/html;charset=gb2312" language="java"%>
<%@page contentType="text/html;charset=gb2312" language="java" %><%
session.setAttribute("session_name","");out.print((String)session.getAttribute("ession_name");
%>
--------------------
对也是我写错了,干脆重写过
<%@page contentType="text/html;charset=gb2312" language="java" %><%
session.setAttribute("session_name","");out.print((String)session.getAttribute("ession_name");
%> ————————————————————
session.setAttribute("session_name",""); out.print((String)session.getAttribute("ession_name");
%>这个代码,在我这里运行没有问题。如果你还是出错的话。肯定是环境问题!
<%@page contentType="text/html;charset=gb2312" language="java" %>
<%
session.setAttribute("session_name","");
out.print((String)session.getAttribute("session_name"));
%>
错误提示为
Method setAttribute(java.lang.String) not found in found in interface javax.servlet.http.HttpSessionMethod getAttribute(java.lang.String) not found in found in interface javax.servlet.http.HttpSession我估计一定是
不同的版本对servlet.jar等javax组件和jdk的要求不同。如Websphere 3.5所要求的servlet.jar 支持的是旧版本的javax.servlet.http.HttpSession操作,不支持session.setAttribute() session.getAttribute()。
并且编译执行过,把resin的work下子目录删掉就好咯。resin毛病多多。。
靠,这个绝对写错
=====================
对也是我写错了,干脆重写过
<%@page contentType="text/html;charset=gb2312" language="java" %><%
session.setAttribute("session_name","");out.print((String)session.getAttribute("ession_name");
%>
session.setAttribute("session_name",);因为你是把变量的值存到session_name中,然后通过out.print((String)session.getAttribute("session_name");就可以了