如何从会话变量中获取内容?

时间:2022-03-14 10:14:26

My situation:

On my jsp site I show a table. When somebody click a row, this row must be marked with an other backround color for example. Also more then one row can be marked. Two things are important. First: I bear in mind which rows are marked. Secend: In which order.

在我的jsp网站上,我展示了一张桌子。当某人单击某一行时,该行必须标有其他背景颜色。还可以标记多行。有两件事很重要。第一:我记住哪些行被标记。 Secend:以什么顺序。

My idea is:

我的想法是:

I have a ArrayList and put all row IDs in this. So I solve both problems. Now I put this ArrayList in the session for the next click and the row ID ( req.getSession().setAttribute(req.getParameter("rowID") , ""+arrayList.size()); ) for the jsp file.

我有一个ArrayList并将所有行ID放入其中。所以我解决了这两个问题。现在我把这个ArrayList放在会话中,用于下一次点击和jsp文件的行ID(req.getSession()。setAttribute(req.getParameter(“rowID”),“”+ arrayList.size());)。

My problem in jsp file:

我在jsp文件中的问题:

I don't now what's called session variable name.

我现在不称之为会话变量名。

if this rowId alrady clicked? ..

如果这个rowId alrady点击了吗? ..

I have got only the bean name. How can I get the content from the session, if exact this line must be marked?

我只有豆名。如果必须标记此行,我如何从会话中获取内容?

Normally I set a session variable so: req.getSession.setAttribut("printView", Boolean.TRUE) and get a session variable so:

通常我设置一个会话变量:req.getSession.setAttribut(“printView”,Boolean.TRUE)并得到一个会话变量:

I work with struts, formbeans and jsp.

我使用struts,formbeans和jsp。

Sorry, I haven't good English and this problem is so difficult for me. So I can't declare it better at this time.

对不起,我的英语不好,这个问题对我来说太难了。所以我现在不能宣布它更好。

1 个解决方案

#1


What about storing the ids of the rows clicked on a JavaScript Map, there you can change its backgound color. Then, to submit this data to the action, just use struts + ajax (see Struts2InAction book chapter 8).

如何存储点击JavaScript地图的行的ID,您可以在那里更改其背景颜色。然后,要将此数据提交给操作,只需使用struts + ajax(请参阅Struts2InAction第8章)。

Also, if your are already uploading the data on the session context, implement SessionAware in your acction in order to be able to access session values.

此外,如果您已经在会话上下文中上传数据,请在您的操作中实现SessionAware,以便能够访问会话值。

Hope this help.

希望这有帮助。

#1


What about storing the ids of the rows clicked on a JavaScript Map, there you can change its backgound color. Then, to submit this data to the action, just use struts + ajax (see Struts2InAction book chapter 8).

如何存储点击JavaScript地图的行的ID,您可以在那里更改其背景颜色。然后,要将此数据提交给操作,只需使用struts + ajax(请参阅Struts2InAction第8章)。

Also, if your are already uploading the data on the session context, implement SessionAware in your acction in order to be able to access session values.

此外,如果您已经在会话上下文中上传数据,请在您的操作中实现SessionAware,以便能够访问会话值。

Hope this help.

希望这有帮助。