这是我在登录页面中编写的代码
HttpSession session = request.getSession(true);
session.setAttribute("name", user1);
String nme=(String) session.getAttribute("name");
Run Code Online (Sandbox Code Playgroud)
而且,这是logout.jsp的代码
<% request.getSession().invalidate();
Run Code Online (Sandbox Code Playgroud)
要么
if(session!=null){
session=null;
}
Run Code Online (Sandbox Code Playgroud)
要么
request.getSession().setAttribute("name", null); //it just assigns null to attribute
response.sendRedirect("login.jsp");
%>
Run Code Online (Sandbox Code Playgroud)
会话正在创建,但在注销按钮工作后....我希望后退按钮不起作用.
我写的像读取tsv文件一样
datarow.splite("\t");
Run Code Online (Sandbox Code Playgroud)
但如果tsv文件包含"\t"它显示\t意味着它正在采取\t正常文本
public class Tsv_read{
public static void main(String[] arg) throws Exception {
BufferedReader TSVFile =
new BufferedReader(new FileReader("users.tsv"));
String dataRow = TSVFile.readLine(); // Read first line.
while (dataRow != null){
String[] dataArray = dataRow.split("\t");
for (String item:dataArray) {
System.out.print(item + " ");
}
System.out.println(); // Print the data line.
dataRow = TSVFile.readLine(); // Read next line of data.
}
// Close the file once all data has been read.
TSVFile.close();
// End …Run Code Online (Sandbox Code Playgroud) 我想搜索添加到列表中的数据.我可以吗?喜欢在数据库中选择查询.
这是我的代码
List<String> list = new ArrayList<String>();
while (dataRow != null){
list.clear();
String[] dataArray = dataRow.split("\t");
for (String item:dataArray) {
list.add(item);
}
Iterator<String> it = list.iterator();
while (it.hasNext()) {
String txt = it.next();
System.out.print(txt+"\t");
}
System.out.println(); // Print the data line.
dataRow = TSVFile.readLine();
}
boolean a=list.contains(72);//////it is not working
System.out.println(a);
Run Code Online (Sandbox Code Playgroud)