最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
j2ee-j2me tips
时间:2022-07-02 17:29:35 编辑:袖梨 来源:一聚教程网
1 . 在J2EE的Servlet中定位resource的绝对地址:
getServletContext().getResource("/WEB-INF/xml/requestmappings.xml").toString();
2. ServletContext 概念:
ServletContext定义了一套用于servlet与servlet 容器通信的方法函数,如获取一个文件的MIME type, 分发请求,或是写日志
一个JAVA虚机的一个web应用具有一个context。
在DD(deploy描述)中标志为"distributed"的web应用,一个JAVA虚机只有一个context实例。在这种情况下,context就不能用于保存global的信息。这是应考虑使用外部资源如database来保存信息
3. IE的encoding 自动选择来源
来自于header的 charset 选项
4. 在有些JSP中为了显示中文字符,必须将字符作如下转变:
String result = new String(transDate.getBytes("utf8"), "iso-8859-1");
5. Lost update问题(两个instance同时在看某个记录,并可能同时进行更改操作,如何避免第一个用户由于第二个用户的修改而导致的更改丢失现象)
有两种方法:
1. Soft lock.(Optimistic Concurrency)
2. Hard lock(Pessimistic Concurrency)
1. Soft lock.
In the case of Soft lock you have use an extra field called timestamp in your
database table. When you are retrieving a record from the database, you need to
store its timestamp in a temporary variable and when user hits the update link
you have to compare this timestamp with the timestamp of most recent record
available in the database. If the timestamp matches you should allow that user
to update the record (because during this spawn of time nobody has updated the
reocrd) otherwise you should display a message stating that "Record is already
updated by somone"
2. Hard lock
In the case of hardlock, while retrieving a record from the database you should
use the query in the form of "SELECT ..FOR .. UPDATE". This will prevent
相关文章
- 永远的蔚蓝星球剑仙怎么样 剑仙获取方法及技能介绍 09-12
- 盛世天下听力达人怎么达成 听力达人达成方法 09-12
- 阴阳师雪御前魂土阵容怎么配-雪御前魂土阵容搭配推荐 09-12
- 失控进化地铁模式怎么玩 地铁模式玩法教学 09-12
- 鸣潮尤诺专武值得抽吗 尤诺专武抽取建议 09-12
- 幻兽帕鲁家园怎么建造 家园建造位置 09-12