随笔-40  评论-66  文章-0  trackbacks-0
 

Cannot retrieve mapping for action

异常
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login (/Login是你的action名字)




可能原因
action没有再struts-config.xml 中定义,或没有找到匹配的action,例如在JSP文件中使用 <html:form action="Login.do".将表单提交给Login.do处理,如果出现上述异常,请查看struts-config.xml中的定义部分,有时可能是打错了字符或者是某些不符合规则,可以使用struts console工具来检查。





Cannot retrieve definition for form bean null

异常
org.apache.jasper.JasperException: Cannot retrieve definition for form bean null

可能原因

这个异常是因为Struts根据struts-config.xml中的mapping没有找到action期望的form bean。大部分的情况可能是因为在form-bean中设置的name属性和action中设置的name属性不匹配所致。换句话说,action和form都应该各自有一个name属性,并且要精确匹配,包括大小写。这个错误当没有name属性和action关联时也会发生,如果没有在action中指定name属性,那么就没有name属性和action相关联。当然当action制作某些控制时,譬如根据参数值跳转到相应的jsp页面,而不是处理表单数据,这是就不用name属性,这也是action的使用方法之一。





No action instance for path /xxxx could be created

异常
No action instance for path /xxxx could be created

可能原因
特别提示:因为有很多中情况会导致这个错误的发生,所以推荐大家调高你的web服务器的日志/调试级别,这样可以从更多的信息中看到潜在的、在试图创建action类时发生的错误,这个action类你已经在struts-config.xml中设置了关联(即添加了<action>标签)。

在struts-config.xml中通过action标签的class属性指定的action类不能被找到有很多种原因,例如:

定位编译后的.class文件失败。Failure to place compiled .class file for the action in the classpath (在web开发中,class的的位置在r WEB-INF/classes,所以你的action class必须要在这个目录下。例如你的action类位于WEB-INF/classes/action/Login.class,那么在struts-config.xml中设置action的属性type时就是action.Login).
拼写错误,这个也时有发生,并且不易找到,特别注意第一个字母的大小写和包的名称。

在struts-config.xml中指定的action类没有继承自Stuts的Action类,或者你自定义的Action类没有继承自Struts提供的Action类。

你的action类必须继承自Struts提供的Action类。

你的classpath的问题。例如web server没有发现你的资源文件,资源文件必须在WEB-INF/classes/目录下。

Problem in struts-config.xml file with action mapping.

Problem with data-sources.xml file.

相关链接
http://www.mail-archive.com/struts-user ... org/msg65874.html
Action Mapping mistake in struts-config.xml:
http://www.manning.com/ao/readforum.ht ... mp;readthread=177
data-sources.xml file?:
http://www.caucho.com/quercus/faq/section.xtp?section_id=30





No getter method for property XXXX of bean org.apache.struts.taglib.html.BEAN

异常
javax.servlet.jsp.JspException: No getter method for property username of bean org.apache.struts.taglib.html.BEAN

可能原因
没有位form bean中的某个变量定义getter 方法

这个错误主要发生在表单提交的FormBean中,用struts标记<html:text property=”username”>时,在FormBean中必须有一个getUsername()方法。注意字母“U”。

Related Links
Case can trip up the matching between get method's name and name specified in Struts tag
http://saloon.javaranch.com/cgi-bin/ubb/ultimate ... c&f=58&t=000163





java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm

错误
java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm

可能原因
这个错误主要发生在在classpath中找不到相应的Java .class文件。如果这个错误发生在web应用程序的运行时,主要是因为指定的class文件不在web server的classpath中(/WEB-INF/classes 和 /WEB-INF/lib)。

在上面的错误中,原因是找不到ActionForm类。

This error is sometimes seen when one or more ActionForm.class instances are actually in the classpath. This most often occurs when ActionForm.class is made available correctly by placing struts.jar in the /WEB-INF/lib directory. When this library has been correctly placed and it is verified that ActionForm.class actually is present in the struts.jar file, the problem is either that more than one copy of ActionForm.class is in the classpath or (more likely) that duplicate versions of class files other than ActionForm are in the same classpath, causing confusion. This is especially true if a class that extends ActionForm is made available twice, such as in an .ear file that encompasses a .war file as well as in the .war file's own classpath (/WEB-INF/classes). This problem can be resolved by guaranteeing that there are no redundant classes, especially those related to Struts (directly from Struts or extensions of Struts), in the web application's view.

相关连接
EJB and Web Shared Links:
http://forum.java.sun.com/thread.jsp?forum=26&am ... ;tstart=0&trange=15
Keep Action and ActionForm (and their children) as non-overlapping unit(s) of an application
http://www.mail-archive.com/struts-u ... ache.org/msg47466.html
http://www.mail-archive.com/struts-user ... org/msg47467.html





Exception creating bean of class org.apache.struts.action.ActionForm: {1}

异常
javax.servlet.jsp.JspException: Exception creating bean of class org.apache.struts.action.ActionForm: {1}

可能原因
Instantiating Struts-provided ActionForm class directly instead of instantiating a class derived off ActionForm. This might occur implicitly if you specify that a form-bean is this Struts ActionForm class rather than specifying a child of this class for the form-bean.

Not associating an ActionForm-descended class with an action can also lead to this error.

Related Links






Cannot find ActionMappings or ActionFormBeans collection

Exception
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection

可能原因
不是标识Struts actionServlet的<servlet>标记就是映射.do扩展名的<sevlet-mapping>标记或者两者都没有在web.xml中声明。

在struts-config.xml中的打字或者拼写错误也可导致这个异常的发生。例如缺少一个标记的关闭符号/>。最好使用struts console工具检查一下。

另外,load-on-startup必须在web.xml中声明,这要么是一个空标记,要么指定一个数值,这个数值用来表servlet运行的优先级,数值越大优先级越低。

还有一个和使用load-on-startup有关的是使用Struts预编译JSP文件时也可能导致这个异常。

相关链接
Explicitly Define <load-on-startup>
http://saloon.javaranch.com/cgi-bin/ubb/ultim ... topic&f=50&t=001055
http://threebit.net/tutorials/ejb/general/





NullPointerException at ... RequestUtils.forwardURL

异常
java.lang.NullPointerException at org.apache.struts.util.RequestUtils.forwardURL(RequestUtils.java:1223)

可能原因
在struts-config.xml中的forward元素缺少path属性。例如应该是如下形式:
<forward name="userhome" path="/user/userhome.jsp"/>





Cannot find bean org.apache.struts.taglib.html.BEAN in any scope

Exception
javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope




Probable Causes
试图在Struts的form标记外使用form的子元素。这常常发生在你在</html:form>后面使用Struts的html标记。

另外要注意可能你不经意使用的无主体的标记,如<html:form … />,这样web 服务器解析时就当作一个无主体的标记,随后使用的所有<html>标记都被认为是在这个标记之外的,如又使用了<html:text property=”id”>

还有就是在使用taglib引入HTML标记库时,你使用的prefix的值不是html。

相关连接
Using form subelements outside of a form tag
http://forum.java.sun.com/thread.jsp?thread= ... &message=1384153





Missing message for key xx.xx.xx

Exception
javax.servlet.jsp.JspException: Missing message for key xx.xx.xx

Probable Causes
这个key的值对没有在资源文件ApplicationResources.properties中定义。如果你使用eclipse时经常碰到这样的情况,当项目重新编译时,eclipse会自动将classes目录下的资源文件删除。

资源文件ApplicationResources.properties 不在classpath中 应将资源文件放到 WEB-INF/classes 目录下,当然要在struts-config.xml中定义)





Cannot find message resources under key org.apache.struts.action.MESSAGE

异常
Cannot find message resources under key org.apache.struts.action.MESSAGE

可能原因
很显然,这个错误是发生在使用资源文件时,而Struts没有找到资源文件。

Implicitly trying to use message resources that are not available (such as using empty html:options tag instead of specifying the options in its body -- this assumes options are specified in ApplicationResources.properties file)

XML parser issues -- too many, too few, incorrect/incompatible versions

Related Links
Provide Struts with Resource Bundle
http://threebit.net/tutorials/ejb/general/
XML Parser Issues
http://www.mail-archive.com/struts-user ... org/msg15779.html





No input attribute for mapping path /loginAction

错误
No input attribute for mapping path /xxxxAction

可能原因e
No input attribute in action mapping in struts-config.xml file for the action with the name specified in the error message. An input attribute is not required if form validation is not performed (either because the validate attribute is set to false or because the validation method in the relevant form class is not implemented. The input attribute specifies the page leading to this action because that page is used to display error messages from the form validation.

Related Links






Strange Output Characters

错误
Strange and seemingly random characters in HTML and on screen, but not in original JSP or servlet.

可能原因
混和使用Struts的html:form标记和标准的HTML标记不正确。

使用的编码样式在本页中不支持。





"Document contained no data" or no data rendered on page

错误
"Document contained no data" in Netscape

No data rendered (completely empty) page in Microsoft Internet Explorer

可能原因
使用一个Action的派生类而没有实现perform()方法或execute()方法。在Struts1.0中实现的是perform()方法,在Struts1.1中实现的是execute()方法,但Struts1.1向后兼容perform()方法。

但你使用Struts1.1创建一个Action的派生类,并且实现了execute()方法,而你在Struts1.0中运行的话,就会得到"Document contained no data" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer.”的错误信息。


posted @ 2006-12-06 16:44 Super·shen BLOG 阅读(478) | 评论 (0)编辑 收藏
Action类

用来访问业务逻辑类。当 ActionServlet 从容器接收到一个请求,它使用URI (或者路径
“path”) 来决定那个Action 将用来处理请求。一个 Action 可以校验输入,并且访问业务
层以从数据库或其他数据服务中检索信息。


ActionForm类

为校验输入或者使用输入来更新数据库, Action 需要知道什么值被提交上来。它并不是强
制每个Action 都要从请求中抓取这些值,而是由 ActionServlet 将输入绑定到JavaBean中。
输入 bean 就是Struts ActionForm 类的子类。ActionServlet 通过查找请求的路径可以决定使
用哪个ActionForm , Action 也是通过同样的方法选取的。ActionForm 扩展了
org.apache.struts.action.ActionForm 类

每个请求都必须以HTTP 响应进行应答。 通常,Struts Action 并不自行渲染响应信息,
而是将请求转发到其他资源,比如JSP 页面。Struts 提供一个ActionForward 类,用来将
一个页面的路径保存为逻辑名称。当完成业务逻辑后,Action 选择并向Servlet 返回一个
ActionForward。Servlet 然后使用保存在ActionForward 对象中的路径来调用页面完成响
应。

Struts 将这些细节都绑定在一个ActionMapping 对象中。每个ActionMapping 相对于一个
特定的路径。当某个路径被请求时,Servlet 就查询ActionMapping 对象。ActionMapping
对象告诉servlet,哪些个Action,ActionForm,和 ActionForward 将要被本次请求使用。
所有这些细节,关于Action, ActionForm, ActionForward, ActionMapping,以及其
它一些东西,都在struts-config.xml 文件中定义。 ActionServlet 在启动时读取这个配置文
件,并创建一个配置对象数据库



举个例子来说,
页面上如果有以下语句:
<html:form action="/hello.do">
当submit此form时,控制器从配置文件中找<action-mappings>下path="/hello" 的<action>元素
然后根据此action元素的type属性找要执行的action类文件
比如

<action-mappings>
    <action path="hello"
            type="cn.com.mylu.Hello"
            name="Hellofrom"
            ……
    </action>

其中 cn.com.mylu.Hellofrom 为ActionForm类javabean
           cn.com.mylu.Hello 为Action类

    <form-bean name="Hellofrom" type="cn.com.mylu.Hellofrom">
    </form-bean>


页面hello.do-----> action元素的path属性 ------> action元素的type属性----->Hello.java---->Hello.java中的execute方法
posted @ 2006-12-06 16:25 Super·shen BLOG 阅读(342) | 评论 (0)编辑 收藏

在讲外连接之前,先举例介绍内连接,也就是一般的相等连接。
select * from a, b where a.id = b.id;
对于外连接,Oracle中可以使用“(+)”来表示,9i可以使用LEFT/RIGHT/FULL OUTER JOIN,下面将配合实例一一介绍。
1. LEFT OUTER JOIN:左外关联

SELECT e.last_name, e.department_id, d.department_name 
FROM employees e 
LEFT OUTER JOIN departments d 
ON (e.department_id = d.department_id);
 

等价于
SELECT e.last_name, e.department_id, d.department_name 
FROM employees e, departments d 
WHERE e.department_id=d.department_id(+);
 

结果为:所有员工及对应部门的记录,包括没有对应部门编号department_id的员工记录。
2. RIGHT OUTER JOIN:右外关联
SELECT e.last_name, e.department_id, d.department_name 
FROM employees e 
RIGHT OUTER JOIN departments d 
ON (e.department_id = d.department_id);
 

等价于
SELECT e.last_name, e.department_id, d.department_name 
FROM employees e, departments d 
WHERE e.department_id(+)=d.department_id;
 

结果为:所有员工及对应部门的记录,包括没有任何员工的部门记录。
3. FULL OUTER JOIN:全外关联
SELECT e.last_name, e.department_id, d.department_name 
FROM employees e 
FULL OUTER JOIN departments d 
ON (e.department_id = d.department_id);
 

结果为:所有员工及对应部门的记录,包括没有对应部门编号department_id的员工记录和没有任何员工的部门记录。

posted @ 2006-11-29 14:32 Super·shen BLOG 阅读(399) | 评论 (0)编辑 收藏

下棋没啥长进,今天用了半个小时看看兵书,总结一下。

开局基本原理:
[尽快集结子力]
[争夺河界]

1。 尽快集结子力

·        如无必要,不要重复走同一子

·        先出炮、马 ,然后车、兵    [车要通 马要灵 炮要能呼应]

·        不可用一两个棋盲目进攻

·        子力要互相呼应,互相配合,不可互相干扰和阻塞

·        若吃兵使用对方能力快速出子或发动攻势,便不要吃

·        若吃兵使用对方能力快速出子或发动攻势,便不要吃


2.       争夺河界 :

除車以外,其他棋子在河界附近都可发挥最大威力及控制力,在中心的棋子要调动到两翼也较灵活、快速,所以河界附近为兵家必争之地。若河界附近被对方占领,便得设法攻下它。反之,自己占据时,须要坚守并利用它向对方的九宮进攻。

中局原理

3.       善用「車」:

4.        在防守中进攻,兼顾协调

5.       保护「士兵」:



关键还是实战时眼光锐利,先人一步。

posted @ 2006-11-21 17:35 Super·shen BLOG 阅读(5814) | 评论 (2)编辑 收藏
String strsql = "select temp.*,rownum  from (select * from tb_awardinfo order by award_id desc )temp where rownum <=5";
//自己乱写的,不知道效率怎么样,那位达人帮贴过代码来参考参考
posted @ 2006-11-21 16:17 Super·shen BLOG 阅读(829) | 评论 (0)编辑 收藏

oracle 分页

1. 最好还是利用分析函数
row_number() over ( partition by col1 order by col2 )

比如想取出100-150条记录,按照tname排序

select tname,tabtype from (
   select tname,tabtype,row_number() over ( order by tname ) rn from tab
)
where rn between 100 and 150;

2. 直接使用rownum 虚列
select tname,tabtype from (
   select tname,tabtype,rownum rn from tab where rownum <= 150
)
where rn >= 100;
使用序列不能基于整个记录集合进行排序,如果指定了order by子句,排序的的是选出来的记录集的排序.

------------------------------------------------------------------------
经过测试,在100万条数据的表中,检索数据的时候,方法2的速度要比方法1要快的.


排序分页

说明:Oracle下用rownum进行分页时 很容易出现排序的错乱。


但多套一层select 就能很好的解决该问题,特此记录,语句如下:

select t2.* from (select t1.*, rownum rn from (select * from tb_courseinfo order by rownum  desc )t1 where rownum <= 150 )t2 where rn >100


不懂具体效率怎么样,和上边一样应该还可以。




实际例子代码如下

int curpage=1;//当前页
int page_record=20;//每页显示的记录数
int introwcount=0; // 记录数
if(request.getParameter("page")==null||Integer.parseInt(request.getParameter("page"))<=0)
{
curpage = 0;
}
else
{
curpage=Integer.parseInt(request.getParameter("page"))-1;//获取传递的值,需要显示的页
}

String sql = "select t2.* from (select t1.*, rownum rn from (select * from tb_courseinfo order by rownum  desc )t1 where rownum <= "+(curpage+1)*page_record+" )t2 where rn > "+curpage*page_record;



posted @ 2006-11-21 16:11 Super·shen BLOG 阅读(4113) | 评论 (3)编辑 收藏

 

sys和system用户的区别
【system】用户只能用normal身份登陆em。
【sys】用户具有“SYSDBA”或者“SYSOPER”权限,登陆em也只能用这两个身份,不能用normal。
“SYSOPER”权限,即数据库操作员权限,权限包括:
  打开数据库服务器   关闭数据库服务器
  备份数据库       恢复数据库
  日志归档         会话限制
“SYSDBA”权限,即数据库管理员权限,权限包括:
  打开数据库服务器   关闭数据库服务器
  备份数据库       恢复数据库
  日志归档       会话限制
  管理功能       创建数据库


normal 、sysdba、 sysoper有什么区别
normal 是普通用户
另外两个,你考察他们所具有的权限就知道了
sysdba拥有最高的系统权限
sysoper主要用来启动、关闭数据库,sysoper 登陆后用户是 public
sysdba登陆后是 sys

SQL> conn / as sysdba
已连接。
SQL> grant sysoper to test;

授权成功。

SQL> conn test/test as sysoper;
已连接。
SQL> show user
USER 为"PUBLIC"
SQL> conn test/test as sysdba
已连接。
SQL> show user
USER 为"SYS"
SQL>

 

 

dba和sysdba的区别
dba、sysdba这两个系统角色有什么区别呢
在说明这一点之前我需要说一下oracle服务的创建过程
·创建实例
·启动实例
·创建数据库(system表空间是必须的)
启动过程
·实例启动
·装载数据库
·打开数据库

sysdba,是管理oracle实例的,它的存在不依赖于整个数据库完全启动,
只要实例启动了,他就已经存在,以sysdba身份登陆,装载数据库、打开数据库
只有数据库打开了,或者说整个数据库完全启动后,dba角色才有了存在的基础!

posted @ 2006-11-20 15:37 Super·shen BLOG 阅读(7632) | 评论 (4)编辑 收藏

一直都是用sql server作为开发数据库,最近因为开发新的项目使用oracle数据库,我才开始学习oracle.
学习了一段时间,发现SQL Server和Oracle还是有这很大的差别。首先,我在SQL Server中用得很顺手的自增长字段就在ORACLE中找不到了,朋友说可以用序列可以实现,于是查阅资料,整理出如下示例:


方法一

1.建立测试数据表
CREATE TABLE TEST
(
 ID NUMBER,
 NAME VARCHAR2(20),
 PRIMARY KEY(ID)
);

2.创建序列
CREATE SEQUENCE SEQ_TEST;

3.创建触发器
CREATE OR REPLACE TRIGGER AUTOINCREMENT
BEFORE INSERT ON TEST
FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT SEQ_TEST.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/

4.插入数据
INSERT INTO TEST(NAME) VALUES('NAME1');

5.查看插入结果
SELECT * FROM TEST;



方法二


SQL   Server,Sybase:  
  有个identity属性可以让系统自动增1  
  create   table   a  
  (  
  a1   int   identity(1,1),  
  a2   varchar(6)  
  )   
  然后在insert时:  
  insert   into   a   values('hello!'); --不用管a1,系统会自动增1  
   
  Oracle:  
  使用SEQUENCE(序列)可以达到要求  
  create   table   a  
  (  
  a1   int   ,  
  a2   varchar2(6)  
  );  
   
  create   SEQUENCE   seq_a     INCREMENT   BY   1;   
    
  然后在insert时:  
  insert   into   a   values(seq_a.nextval,'hello!'); --seq_a.nextval是该序列的下个值

posted @ 2006-11-20 00:39 Super·shen BLOG 阅读(649) | 评论 (0)编辑 收藏

每天都在赶项目,只能用自己认为比较快的方式制作了!


写好几个类,写好几个页面, 每天在复制粘贴代码!!晕死

其实我也想弄高质量的东西,没有时间了


我想干类似我这种活的人不少
严重怀疑中国软件的质量



周末得加一天班了

弄个效果图上

posted @ 2006-11-16 23:29 Super·shen BLOG 阅读(413) | 评论 (0)编辑 收藏
来公司上班已经两个月了,虽然工作相对来说不累, 但工作之余,内心总是感觉前面的路不是很清晰。

过去一两年我一直在做WEB项目的开发, 包括网站,自助建站系统,OA办公系统等。因为一直在小公司干,专职的只有两个程序员,所以基本每种技术都会一些(ASP,PHP,JSP,ASP.NET,MSSQL,MYSQL,ORACLE都有用过开发有案例),但明显深度不够,用得最好的算是VS2003开发ASP.NET吧。



最近这个月,我们老总接了一个朋友的单子,是一所专科学院的OA系统, 公司有一个JAVA程序工程师(听说这个人很牛,在IBM中国做过1亿多的项目)做了一个方案,用JAVA的什么什么技术实现( Struts+spring+hibernate+EJB),并报了个概价约20万,提交到学校,学校没有回音。

老总说这个月初,学校说要做了,并签了合同 大概15万(具体我没得看)。

刚好上个月月尾,公司的唯一牛人 JAVA程序工程师辞职了。

老总就把这个项目扔给我做,我表示我没这个能力,我对JAVA 的Struts+spring+hibernate+EJB 多层架构根本不熟悉,他以为我在推托责任,老总叫我到办公室说了一大堆理由,最终我没说过他!我还是得做!(补充:老总对计算机技术是个文盲,是个很厚道的很有钱人。 有一次很搞笑,他叫我帮他换个显示器用,正在换的时候,他给我说:“你要记得把我原来电脑桌面上的文件保留下来啊” 我汗,我差点倒地)。

现在我硬着头皮在搞这个项目,由于对JAVA 的Struts+spring+hibernate+EJB 多层架构不懂,而项目又一定要用JAVA 做,时间又紧,40天完成,只有我一个人做,我只能直接用JSP + JAVABEAN+ORACLE做了!

现在已经过去10天了,估计才完成1/3。
估计以后得加班了,应该能按时交付。


但是,总感觉我这条路走得不对,做来做去都是一些没什么价值的东西,没有深度的东西, 现在什么年代了,还用在JSP+JAVA BEAN开发,没长进啊。
 

感觉我大学毕业时基础也不差,也通过了程序设计师考试,毕业时候还混得个好工作。 但是这两年混错了方向,这里搞搞 那里搞搞,但都不深入学习,两年就这样过去了!现在再来深入学习JAVA 还行吗。。。。
posted @ 2006-11-15 16:41 Super·shen BLOG 阅读(564) | 评论 (2)编辑 收藏
仅列出标题
共4页: 上一页 1 2 3 4