项目中常见的错误

2023-05-16

项目中遇到的错误(c9bcf64c)
sql错误

找不到列
Unknown column 'fillMen' in 'field list'

2.列名在sql语句中写了2次
Column 'fillMan' specified twice


3.下面2条 数据库插入对应的列都是int类型的 所插入的数据类型不符合要求时报错
Data truncated for column 'gatheringMoney' at row 1

Data truncation: Out of range value adjusted for column 'amount' at row 1


4.
Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause


5.修改一个表时无法取得同一个表的数据
ERROR 1093 (HY000): You can't specify target table 'context' for update in FROM
clause

6.主键 未自动增长
ERROR 1062 :

7.int 类型字符过长
com.mysql.jdbc.exceptions.MySQLDataException: '2.5026744582E10' in column '1' is outside valid range for the datatype INTEGER.


8.没找到错误 没影响数据读取
java.sql.SQLException: Operation not allowed after ResultSet closed

9.类型错误 最常见的是数字类型错误
Data truncated for column 'gatheringMoney' at row 1

10.换另一个项目时 数据库连接池没换 (未解)
Name java: is not bound in this Context
换了之后 似乎还是不行
=====
java:/comp/env/jdbc/ConnSqlSer
前面多了一个'/'
应为java:comp/env/jdbc/ConnSqlSer
=======
11.\(未解)
java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in

12.executeQuery()方法改成execute()(未解)
Can not issue data manipulation statements with executeQuery().

Can not issue data manipulation statements with executeQuery().

struts错误

Failed to obtain specified collection 下拉框没值
警告: No FormBeanConfig found under 'yuanLiaoRuKuForm' 配置文件Form出错


Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope
<html:text >标签外面没有嵌套<html:form >标签

No getter method for property: "outDate" of bean: "com.System.storage.form.YuanliaoPandianForm"
在form里面没有定义 此字段的get方法


Cannot get a connection, pool error Timeout waiting for idle object 数据库错误

Operation not allowed after ResultSet closed 可能是结果集关闭了


//在Action里面调用的DAO类 没有进行重新实例化
2008-5-12 20:02:09 org.apache.struts.action.RequestProcessor processException
警告: Unhandled Exception thrown: class java.lang.NullPointerException
2008-5-12 20:02:09 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet action threw exception
java.lang.NullPointerException
at com.System.storage.action.FinishedAction.finishedCheckAdd(FinishedAction.java:151)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

//在C标签里从一个对象里取值时 , 所请求的是对象里没有的属性
An error occurred while evaluating custom action attribute "value" with value "${rows.storageAmount}": Unable to find a value for "storageAmount" in object of class "com.System.storage.domain.Finished" using operator "." (null)


forward 转向 连接到了一个还没开始写的action里面 而那个action所对应的jsp页面还没改
Resources cannot be null.

找不到下面这个action
Cannot retrieve mapping for action /finished/finishedChuKuSearch
Cannot retrieve mapping for action /purveyAdd 如果把jsp页面的action写错了 就这样报

/jspfinance/client/ShouKuanJiLu_Sel.jsp(172,0) The end tag "</html:form" is unbalanced

类型转换错误 一般是参数类型写错 在公共方法或者配置文件里面找
com.System.finance.client.form.GatheringForm cannot be cast to com.System.finance.client.form.InvoiceForm

struts标签里面 写进了html标签内的属性
/jspclient/KeHuDangAn_Ins.jsp(44,88) equal symbol expected
/jspfinance/client/TuiHuanHuo_Ins.jsp(70,42) quote symbol expected
/jspstorage/material/YuanLiaoChuKu_Ins.jsp(84,31) equal symbol expected
org.apache.jasper.JasperException: /scDept/dingDanXinZeng.jsp(333,167) equal symbol expected


jsp页面上action写错了
Cannot retrieve mapping for action /finished/finishedCheckAdd


配置文件出错
The content of element type "action-mappings" must match "(action)*".


java常见错误以及可能原因集锦

2008-07-08 15:550、 需要标识符
a) 不在函数内

1、 非法表达式开始
b) 可能:丢失括号 .

2. no data found
a) 可能:setInt(1,100)中,没有100这个值

3. 找不到符号
a) 可能:没导入包

4. 指定了无效URL
a) 可能:数据库名或IP错误,即连接出错

5. 类路径没有找到
a) 可能: ClassNotFoundException: oracle.jdbc.driver.OracleDriver
b) 原因: 一般是指包名写错,或者没有import包,或者没有在类路径中找到jar文件
c) 解决: 没有加载Oracle驱动jar,在.bash_profile中把ojdbc14.jar加进来

6. 空指针异常
a) 可能: 数据源错误 比如数据库名或IP错误

7. 不能执行查询
a) 可能: 数据库中表的问题,比如列名不存在

8. invalid identity
a) 可能: 列名出错

9. 若在数据库中创建了 两个sequence ,运行时出现异常可能是先后执行了多次select语句,导致与原有的序列号产生冲突

10. 表名或列名不存在
a) 可能:表不存在或者没有插入数据到表中

11. 不支持的类,类的版本错误
a) 可能:没有导入jdk5.0,或者编译器仍为1.4

12. MappingNotFoundException
a) Maybe: In the Eclipse Not refersh , or not exist in the dirctory

13. HibernateException: /hibernate.cfg.xml not found
a) Maybe1: hibernate.cfg.xml not in the root directory
b) Maybe2: Could not parse configuration .
c) resolve: database not connect or use another database

14. ConstraintViolationException
a) Maybe: used a not true database

15. 驱动没有找到 或者 JDBC Driver not found
可能:连接数据库的驱动jar包不存在或者版本不一致,比如将旧的版本换成新的会造成该类错误
16. 空指针异常 , java.lang.NullPointerException
a) 可能1:数据库连接出错,比如在hibernate.cfg.xml中的数据错误会导致异常。

17. 数据插入异常 ,GenericJDBCException: could not insert
a) 可能1:没有建立表或者表中没有任何数据
b) 可能2:插入数据后没有执行提交语句:commit

18. LazyInitializationException 或者延迟加载异常
a) 可能1:没有在查询语句中加fetch

19. IdentifierGenerationException
a) 可能1:高位表没有初始化(比如hi_value中没有记录)

20. could not initialize a collection: [hibernate.entity.Role.modules#32768] Syntax error: Encountered "-" at line 1, column 132.
a) 错误原因:><set name="modules" table="module-role" lazy="false">红色字部分中“-”为非法字符,替换为module_role

21. could not insert collection rows: [hibernate.entity.Module.roles#1]
在Module.hbm.xml文件的如下配置中加入inverse=”true”
<set name="roles" table="module_role" inverse="true">

22.在部署Struts时,出现如下错误信息:
HTTP Status 404 - Servlet action is not available

type Status report
message Servlet action is not available
description The requested resource (Servlet action is not available) is not available.
问题原因:
1.、web.xml文件中未配置ActionServlet。
2、struts-config.xml文件未配置你要访问的Action。
3、你的jsp文件form标记中action属性的路径名称错误。
4、非以上三种情况。
针对以上4种情况相应的解决方案如下:
1、在web.xml文件中加上ActionServlet的配置信息
?????? /WEB-INF/struts-config.xml?
?2、在struts-config.xml文件检查你要访问的Action配置文件。
3、检查jsp文件form标记中action属性的路径名称是否与struts-config.xml文件中action标记的path属性的路径名称一致。
4、非以上情况的解决办法就是检查web容器的log日志,如果时tomcat则检查下logs目录下的localhost_log文件,看里边是否记录有错误信息,然后根据错误信息提示将其纠正。

23.java.lang.NoClassDefFoundError: org/apache/commons/beanutils/Converter
缺少spring-framework-2.0.3\lib\jakarta-commons\commons-beanutils.jar

24.
ava 代码Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/Type
缺少spring-framework-2.0.3\lib\asm\asm-2.2.2.jar包,版本不同,该包的名字有相应的区别

java 代码Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException
缺少spring-framework-2.0.3\lib\dom4j\dom4j-1.6.1.jar包,版本不同,该包的名字有相应的区别
把这个包进去就可以了:\Spring206\lib\dom4j、dom4j-1.6.1.jar

java 代码Caused by: java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap
缺少spring-framework-2.0.3\lib\jakarta-commons\commons-collections.jar包,版本不同,该包的名字有相应的区别

java 代码Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/CallbackFilter
缺少spring-framework-2.0.3\lib\cglib\cglib-nodep-2.1_3.jar包,版本不同,该包的名字有相应的区别

java 代码Caused by: java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
缺少hibernate-3.2\lib\asm.jar包,版本不同,该包的名字有相应的区别

java 代码
org.hibernate.exception.SQLGrammarException: could not load an entity: [www.proudsoul.xml.User#1]
JAVA工程与WEB工程包的区别:一个是asm.jar,一个是jta.jar

java 代码Caused by: java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
缺少spring-framework-2.0.3\lib\j2ee\jta.jar包,版本不同,该包的名字有相应的区别此种错误请检查相应的***.hbm.xml配置文件的配置

25,
Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not get next sequence value; nested exception is org.hibernate.exception.SQLGrammarException: could not get next sequence value
Caused by: org.hibernate.exception.SQLGrammarException: could not get next sequence value
原因:没有加Sequence或者数据库的方言写错了

26,
我的配置文件
<id name="id" column="id">
<generator class="native" />
</id>
然后我运行保存一条数据进去
The database returned no natively generated identity value
就会报这个错误
因为你native是根据看底层数据库的能力选择identity, sequence 或者hilo中的一个
而我建表的时候id没有指定
alter table `student` change `id` `id` int auto_increment
我们把我们的表的结构小小的改动一下就没问题了

27,
UpdateManager无法启动2007-08-09 15:21如果在应用程序安装过程中,暴力中断安装程序,会出现如下状况:1.apt-get remove 和dpkg --remove 无法删除软件 2.UpdateManager无法启动3.新立得软件包管理程序无法启动
以上可能是deb损坏之类造成的
sudo dpkg -r sqldveloper
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
E: 软件包 sqldeveloper 需要重新安装,但是我无法找到相应的安装文件。
解决方法:1.从 /var/lib/dpkg/status 中把对应的段删掉
重要:修改之前请先备份
在status中找到你对应的包删除就OK了...

28,
Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException
少了antlr-2.7.5H3.jar包,从D:\eclipse\eclipse\plugins\com.genuitec.org.hibernate.eclipse_4.1.1\myeclipse-data\3.0\lib

29,
Caused by:
java.lang.NoClassDefFoundError: javax/transaction/Synchronization
缺少Spring206\lib\j2ee\jta.jar

30,
Caused by:
java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [business.impl.PriceBiz] for property 'priceBiz': no matching editors or conversion strategy found
在java类中设置priceBiz时应该设置的是接口PriceBizIf,而非实现类

31, 数组越界
可能1: 在命令行后面需要加入参数.
可能2:加入的参数错误
32, car is not mapped
可能1: 在cfg.xml中没有增加映射的hbm.xml文件在<mapping.../>中

33, 属性没有找到
可能1: hbm.xml文件中的 <property name =""> 有问题, 也许是name的值与对应类中的成员名不一致

34,SQLException: 无当前连接 可能1:在比如创建帐户时没有对相应的方法添加到<list>中去,比如这个没有加入:<value>newAccount</value>

<bean id="transactionAdvisor" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="advice">
<ref bean="advice"/>
</property>
<property name="mappedNames">
<list>
<value>transfer</value>
</list>
</bean>


35,SQLException: Syntax error: Encountered "table" at line 1, column 8.
可能1;执行SQL时出现冲突,可能是SQL语句中使用了关键字作为变量来用,比如
update order set balance=1000000;
其中order被用作表名来使用,这是错误的,因为order是个关键字,用在order by中

36, Servlet /Spring-WebMvc threw load() exception
org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
jar包的冲突,spring-1.2.6.jar和spring.jar出现在一个war的目录中:J Boss/server/all/deploy/Spring-WebMvc.war/WEB-INF/lib

37, java.sql.SQLException: 当事务仍处于活动状态时,无法关闭连接。


38 ,
validateJarFile(/home/soft01/Tomcat/webapps/sms-token-struts/WEB-INF/lib/servlet-api.jar)
Servlet /sms-struts-tiles threw load() exception
java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet
原因:在WEB-INF/lib/ 目录下有servlet-api.jar与/Tomcat/common/lib目录下的servlet-api.jar冲突了,把WEB-INF/lib/下的servlet-api.jar删除就可以了

39,java.lang.ClassNotFoundException: org.springframework.web.struts.ContextLoaderPlugIn
Marking servlet action as unavailable
10:30:47,088 ERROR [/NetCT_OSS]:3953 - Servlet /NetCT_OSS threw load() exception
javax.servlet.UnavailableException

40,org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
缺少MyEclipse/eclipse/plugins/com.genuitec.eclipse.springframework_5.5.0/data/2.0/dist/modules/spring-struts.jar

41,Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (SD0702.FK82D343CF49A4B831) violated - parent key not found
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
有可能是ID生成策略的问题,我将它XML映射文件改成<generator class="increment" />就好了

42,
2007-08-19 16:21:43,290 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/OSS].[action]] - Servlet.service() for servlet action threw exception
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [entity.Module#2]
java.util.ConcurrentModificationException
原因:已经有对象拥有了所选择的module,用clear(),而不是remove();

43,
ERROR [org.apache.catalina.session.ManagerBase] - IOException while loading persisted sessions: java.io.InvalidClassException: entity.Module; local class incompatible: stream classdesc serialVersionUID = -5988350031935445758, local class serialVersionUID = -297934247726484429
java.io.InvalidClassException: entity.Module; local class incompatible: stream classdesc serialVersionUID = -5988350031935445758, local class serialVersionUID = -297934247726484429
在Module中加上一个关键字:transient

44,
Caused by: java.sql.BatchUpdateException: ORA-02292: integrity constraint (SD0702.SYS_C00132664) violated - child record found
原因:有其他的表引用了该表的外建,所以报这个异常,如果没有引用就不会出现

45,
出现数组越界的时候,看看是不是循环时没有加=,比如:
for(int i = 1; i<arr.length;i++)可以改成
for(int i = 1; i><=arr.length;i++)


46.如果使用Ant和Junit是被报找不到test,检查一下是否误用了private
出错信息:
<failure message="No tests found in test.AllTest" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: No tests found in test.AllTest
该错误有个很特别的特点,当你不通过ant来运行测试,而是通过AllTest类来运行的话,可以正常运行。小心哦

47.如果遇到报:表名无效,且jvm报严重错误,看看是不是用了数据库的保留关键字来做表名了,如User。

48.使用ant时必须小心ant的classpath它用的不是IDE的classpath,小心!

49.小心下边的异常,
exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of xp.bean.Users.?" type="net.sf.hibernate.PropertyAccessException">java.lang.ClassCastException at xp.bean.UsersMetaClass1.setPropertyValues(<generated>) at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues
上次出现该错错误的原因是:
源文件里我的class类型为一个类Contact contact
而跑到mapping里却成了Set,呵呵厉害。

50.突然间冒出大量的NullPointException
重新build一下。

51.="Flush during cascade is dangerous - this might occur if an object was deleted and then re-saved by cascade"

52.Tapestry的出错信息:
Class com.bookshop.Hello does not implement the IPage interface.
location: context:/WEB-INF/Home.page, line 6
原因:与显示有关的哪个java类没有从IPage家族继承。

53.使用ant时给出的路径好象不允许出现空格。

54.由于使用ant时用junit做测试的话,classpath中出现j2ee.jar的话,问题多多。例如xml格式的log文件生成不了,莫名其妙的NullPointException等。所以我设置了两个包个包含j2ee.jar,为编译用;一个没有,为junit用

55.进行单元测试时,在查询返回后应马上assertNotNull(),这样可以更快速的定位NullPointException

56.要使用ResourceBundle的话,要千万小心。必须用日志记录下它的状态。还有该属性文件应该放在classes下面。

57.当要显示任何页面时,都被提示无效,那么应该检查一下lib目录了,还有一些很奇怪的异常,例如你明明可以找到一个类但是服务器却提示ClassNotDefException,那么估计是缺少了该类所必须的包了。或者多了不兼容的包,如, xdoclet系列包不被struts的lib目录所兼容

58.编写clone时从Java编程思想(2nd)上学到的(732):
.引数传递过程中会自动产生别名(alias)。
.没有局域对象(local objects),只有局域性的(local)references。
.reference受范围(scope)的限制,对象则否。
.对象的寿命从来不是Java的讨论议题(因为有垃圾回收机制)

59.try catch finally的域居然是分离的。

60.jsp乱码的其中一个原因:charset="gb2312" 等号"="的两边不允许有空格。

61.我的基于Displaytag的简单报表解决方案。
http://displaytag.sourceforge.net/
下载displaytag.jar和displaytag.tld
displaytag.jar放在lib目录,而displaytag.tld放在WEB-INF目录,在web.xml中为displaytag.tld声明一下。
<taglib>
<taglib-uri>http://displaytag.org</taglib-uri>
<taglib-location>/WEB-INF/displaytag.tld</taglib-location>
</taglib>
在jsp里使用前,加上
<%@ taglib uri="http://displaytag.org" prefix="display" %>

注意该软件有个bug,他要用的一个包common-lang.jar版本必须在2.0以上。
如果碰到下面异常,则应坚持一下是否该包的版本问题。
java.lang.NoSuchMethodError: org.apache.commons.lang.StringUtils.capitalize(Ljava/lang/String;)Ljava/lang/String;
然后就可放心使用了
<display:column property = "xxx"/>其中xxx为对象中的带有getter的变量>。
定义表格的样子,用css定义。如
TABLE.its THEAD TR {
BACKGROUND-COLOR: #69c
}
TABLE.its TR.even {
BACKGROUND-COLOR: #def
}
在使用分页时,可能会出现这种情况,点击其他页时,弹出下载窗口,让你下载当前jsp页面,这是因为你在当前页面读取了数据的缘故。解决办法为在action里读取数据而不是在jsp里。可以参考
http://www.displaytag.org/example-paging.jsp?d-26189-p=2

62.使用displaytag时,在一列中放入多个元素
必须在display:table中定义一个id
<display:table name = "allBooks" class = "its" pagesize = "5" id = "item">
<display:column title = "操作">
查看
编辑
删除
</display:column>
要在displaytag中使用链接,必须具备paramId,否则不显示为链接
<display:column property = "product.name" href = "viewDetailV2.0.jsp" title = "书名" paramId="item" paramProperty="product.id"/>
可以这样使用display
<display:column property = "product.id" title = "ID"/>
其中product为对象

63.<bean:write name = "xxxx" property = "xxx"/> 可以直接取到session.getAttribute()取到的东西。

64.实验struts-upload例子时要注意的地方:
1.If you would rather write this file to another file, please check here:
这一行要打钩
2.If you checked the box to write to a file, please specify the file path here:
在这里要重命名如:c:\b.jpg
上传成功的话,会出现提示 The file has been written to "c:\b.jpg"

65.Hibernate的like可以这么用:
Query query = session.createQuery("from src.persistent.Book as book where upper(book.name) like :name ");
query.setString("name", "%");
result = query.list();

66.Hibernate出现 duplicate import : className
异常也可能是因为忘了为持久类在configuration中addClass了

67.<logic:iterate id = "author" name = "authors">
name所引用的是session里的attribute。

68.如果发现要出现询问下载的情况,有可能是因为要跳转的页面出现了问题。试试在要跳转到的页删掉
<%@ page contentType="text/html; charset=gb2312"%>

69.如果JSP页面跳转时出现下边的错误信息:
The request sent by the client was syntactically incorrect (Invalid path /web/shoppingCart was requested).
原因是struts-config的action = "x" 写成了 action = "x.do"

70.在struts中,strut-config.xml中,forward时使用redirect = "true"可以将.do重定向为.jsp

71.以后在判断相等性之前先用logger把两个值显示出来。

72.从session里getAttribute后,修改并不需要重新setAttribute一次。

73.在hibernate中使用subclass是一棵继承树共用一个表,仅生成个mapping。
每个类中必须有discrimator-value。在最上层的类中必须声明:
@hibernate.discriminator column = "class"。
不可以将子类添加到configuration里去。(即不可addClass(子类))
使用Xdoclet的建立subclass的例子(该类是父类)
/**
* @hibernate.class discriminator-value = "customer"
* @hibernate.discriminator column = "class"
*/

而使用joined-subclass则是一类一表,也不许将子类添加进configuration里去。
/**
* @hibernate.joined-subclass
* @hibernate.joined-subclass-key
* column="customer_id"
*/
如果发现生成的mapping文件中joined-subclass的key column为空,那么可能是@hibernate.joined-subclass-key这句没有写对。
用joined-subclass生成的表,仔细看。Member extends Customer
create table Customer (
id VARCHAR2(255) not null,
name VARCHAR2(255),
description VARCHAR2(255),
primary key (id)
)
create table Member (
customer_id VARCHAR2(255) not null,
password VARCHAR2(255),
primary key (customer_id)
)

74.在junit中尽量使用assertEquals代替assertTrue;

75.Hibernate
如果Child extends Parent
那么from Parent as parent 也将会将Child选出来,而from Child as child 则不会选出Parent

76.Hibernate
使用hibernate的one-to-one时,应该两方向都set,否则会报save NullPointException
parent.setChild(child);
child.setParent(parent);

77.Hibernate
遇到下边的异常,估计是与因为外键出现了问题:

java.lang.NullPointerException
at net.sf.hibernate.persister.AbstractEntityPersister.getPropertyValue(AbstractEntityPersister.java:675)
at net.sf.hibernate.id.ForeignGenerator.generate(ForeignGenerator.java:33)
如:
* @hibernate.id generator-class = "foreign"
* @hibernate.generator-param name = "property" value = "customer"
* @hibernate.one-to-one name = "custmoer" class = "src.persistent.Customer"
value的值和one-to-one 中name的值不符,则会出现上边的异常。如果不显示指定name则默认取成员变量名

Customer a
则name = "a" 需要小心的是不是类名。所以,以后最好显示指定名字为好。

78.出现异常:
Exceptionobject references an unsaved transient instance - save the transient instance before flushing: src.persistent.Product
原因没有为某对象进行set设置, 如上边的这个就是某对象没有调用setProduct

79.
"xxx action = "/a" 不用.do和根目录名

80.
Caused by: java.sql.SQLException: ORA-02291: 违反完整约束条件 (BOOKSHOP.FK4AAEE
47687CCA6B) - 未找到父项关键字
如果你觉得该做的e是出现这个问题,那么检查一下,是否将类的继承关系在hibernate的mapping中反映了出来。joined-subclass或subclass
例如a extends b
如果持久类c 需要Set的是持久类a,那么你把b传入,而b又没有在mapping中将父子关系反映出来的话,就会出现该异常

81.使用DynaActionForm需要注意的问题
在struts-config声明
><form-bean name="memberloginForm" dynamic ="true" type="org.apache.struts.action.DynaActionForm">
<form-property name = "name" type = "java.lang.String"/>
<form-property name = "password" type = "java.lang.String"/>
</form-bean>
在Action里将form强制转化成DynaActionForm,然后get("属性名")就可以了

82.struts的validate最简单实现
1.首先准备好错误提示信息。
xxx.properties 里
errors.required={0} is required.(默认已有)
2.Form必须从ValidatorForm继承
3.不可以重载ValidatorForm的validate函数
4.在validate.xml中为你想验证的表单进行验证设计。例如
<form name="logonForm">
<field property="userName" depends="required">
<arg0 key="prompt.userName"/>
(该参数将在显示错误信息是从xxx.properties读取prompt.userName,填入{}方括号里,取代0。如果是arg1将将填入{1}位置,以此类推。
</field>
</form>
不需要在action里做任何处理。只管forward就行了。作为forward的目标页,不需要任何有关用于处理出错信息的处理。

83.服务器报
The requested resource (/xxxx/xxx.htm) is not available.的很奇怪的一个的可能原因
在web.xml中定义的tld,没有找到
或者是lib目录下的包太多出现了问题。

<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/spring.tld</taglib-location>
</taglib>
如WEB-INF目录下不存在spring.tld的话,就会报上边的错误

84.
spring的xxx-servlet.xml的使用SimpleFormController系列的类问题:
<bean id = "priceIncreaseForm" class="PriceIncreaseFormController">
<property name="sessionForm"><value>true</value></property>
<property name="beanName"><value>priceIncrease</value></property>
<property name="commandClass"><value>PriceIncrease</value></property>
<property name="formView"><value>priceIncrease</value></property>
<property name="successView"><value>hello</value></property>
<property name="productManager">
<ref bean="prodMan"/>
</property>
</bean>
这里要注意几个问题:
(1)上边的PriceIncrease是了类名,必须在classes里存在该类,否则报:
PropertyVetoExceptionsException: 1 errors:-- ErrorCodedPropertyVetoException: message=[Failed to convert property value of type [java.lang.String] to required type [java.lang.Class] for property named 'commandClass'; nested exception is:
java.lang.IllegalArgumentException: Invalid class name [PriceIncrease]: PriceIncrease]; errorCode=[typeMismatch]
java.lang.IllegalArgumentException: Invalid class name [PriceIncrease]: PriceIncrease
(2)<property name="formView"><value>priceIncrease</value></property>
这一行必不可少,priceIncrease是页面的名字,他将会是prefix + priceIncrease + suffix
如果缺少该行,则报:
javax.servlet.ServletException: Error in ModelAndView object or View resolution encountered by servlet with name 'pocketSpring': View to render cannot be null with ModelAndView [ModelAndView: materialized View is [null]; Model=[{priceIncrease=PriceIncrease@148e798, org.springframework.validation.BindException.priceIncrease=org.springframework.validation.BindException: BindException: 0 errors}]]

使用Errors的rejectValue相关问题:
rejectValue(java.lang.String field, java.lang.String errorCode, java.lang.Object[] errorArgs, java.lang.String defaultMessage)
Reject the given field of the current object, using the given error description.
当前对象指的是xxx-servlet.xml中与validator类有联系的哪个对象。

第一个是:当前对象的属性名,必须存在
第二个是:将要从属性文件中读取的消息
第三个是:传递给所读取的消息的参数,如:
error.too-low=You have to specify a percentage higher than {0}!
第四个是:当从属性文件中读取消息不成功时,所reject的值

以后从request中读取parameter可以借用spring的RequestUtils包里的
getStringParameter
public static java.lang.String getStringParameter(javax.servlet.http.HttpServletRequest request,
&bsp; java.lang.String name,
java.lang.String defaultVal)
Get a string parameter, with a fallback value. Never throws an exception. Can pass a distinguished value to default to enable checks of whether it was supplied.
不会抛异常
Hibernate的问题:2.1rc的问题
INFO: cache provider: net.sf.ehcache.hibernate.Provider
net.sf.hibernate.HibernateException: could not instantiate CacheProvider:
解决办法,2.1rc比以前的版本多需要一个包
ehcache.jar

85.static的问题
static函数只可以访问static成员变量。
而static变量可以被任何成员函数访问。

86.
java.lang.NoClassDefFoundError: javax/transaction/Synchronization];
需要添加JTA.jar
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

项目中常见的错误 的相关文章

  • Centos7安装Redis

    今天和大家分享如何在Centos7上部署Redis数据库 xff0c 感兴趣的小伙伴可收藏 目录 一 准备工作 二 搭建服务器 三 部署Redis 3 1 远程登录我们的服务器 3 2 配置Redis 3 3 测试Redis 3 4 服务器
  • 详细介绍云服务器购买并使用

    由于原先的服务器块过期了 xff0c 所以今天和大家分享一下如何从头开始购买云服务器并使用 目录 一 详细步骤 1 选择服务器 xff1a 2 购买服务器 xff1a 3 配置服务器操作系统 4 进入控制台 5 管理服务器 6 登录系统实例
  • SDN初学者之路

    今天重新开始拿起SDN完成我的关于SDN控制器下关于交换机迁移的负载均衡问题研究 以此对于SDN 43 RYU 43 多控制器 43 交换机迁移 43 负载均衡相关进行整理记录 其中 xff0c 主要研究内容是交换机迁移过程中的路径最优化选
  • 腾讯云短信服务(详细教程-Django框架、API接口)实现

    今天和大家分享如何实现短信服务 xff0c 以腾讯云服务为例 目录 一 准备工作 二 短信服务接口开发 2 1 服务配置 2 2接口开发 三 测试短信服务 四 结束语 一 准备工作 腾讯云短信服务会发放免费的个人认证短信和赠送短信总共200
  • Pytest测试框架基础篇

    今天和大家分享一下pytest测试框架的基础篇 xff0c 内容包括 xff1a 了解pytest测试框架的特点 掌握pytest基本使用 掌握pytest常用的场景 掌握pytest运行参数和配置方法 目录 一 测试框架的作用和类型 1
  • Pytest测试框架进阶篇

    今天和大家分享pytest测试框架进阶篇 xff0c 也可以称之为pytest测试框架核心 xff0c 主要核心有 xff1a 掌握pytest fixture 掌握pytest mark 目录 一 掌握pytest fixture 1 1
  • PowerDesigner--快速创建表模型生成SQL语句

    今天和大家分享一个我常用的设计表模型的工具PowserDesigner 选择物理模型 创建表 字段 索引等 梳理表之间的关系 一键生成SQL语句 目录 一 准备工作 二 选择物理模型 三 创建表 字段等 3 1 创建表 3 2 创建字段 3
  • python读取txt文件内容并进行分析

    今天和大家分享一下python如何读取txt文件内容并进行数据分析的 需求 某txt文件中存在很多数据 这些数据的某一个属性主要分为A B C D四类 xff0c 要求把数据分成四类求某一数值属性的平均值 xff0c 并统计生成超过平均值两
  • python脚本控制服务器---paramiko的使用

    今天和大家分享一个第三方库paramiko xff0c 主要应用场景是在实现自动化操作服务器时使用 xff0c 模拟我们手动登录服务器 输入cmd命令等操作 最后封装成自己的工具 xff0c 方便后面调用 目录 一 安装paramiko 二
  • Vim编辑器常用快捷方式

    这几天在学习shell编程 xff0c 其中常常会用到Linux下的vim编译器 xff0c 今天就总结一些在vim编辑器中常用的快捷键 xff0c 方便我们更好的使用 目录 一 vi编辑器基本概念 二 模式切换 三 编辑模式 四 命令行模
  • Linux面试相关知识点看着一文就够了

    今天和大家分享一下linux操作系统下主要用到的几个知识点 xff0c 分别是 xff1a linux目录结构 linux常用命令 文件权限操作 服务操作 yum安装命令 docker服务 vim编译器 pymysql测试连接 用户及组命令
  • Python对象比较及深浅拷贝

    今天和大家分享一个python语言中特别重要的一个知识点 xff0c 比较及拷贝 目录 一 61 61 和 is 二 深浅拷贝 2 1 浅拷贝 2 2 深拷贝 三 总结 一 61 61 和 is 等于 61 61 和is是Python中对象
  • python中的值传递和引用传递

    今天和大家分享python中很重要的一个知识点 xff1a 参数传递 xff0c 其中包括值传递和引用传递 目录 一 为什么要熟悉值传递和引用传递 1 1 值传递 1 2 引用传递 二 Python变量及其赋值 三 Python函数的参数传
  • MySQL8.0下DATE,DATETIME和TIMESTAMP的自动初始化和更新

    MySQL8 0下DATE DATETIME和TIMESTAMP的自动初始化和更新 DATE日期类型DATETIME和TIMESTAMP的不同什么是时区自动变动 xff1f DATETIME和TIMESTAMP的相同点微秒小数部分自动初始化
  • Python爬虫实战分析

    今天看到特别好的一篇文章 xff0c 分享给大家 从头到尾看了一遍 xff0c 以实战的例子分析爬虫所需要用到的知识点 十分受益 真可谓 xff1a python万能模板 xff0c 有了这个模板 xff0c 想爬取什么内容 xff0c 根
  • ansible dns

    1 详细叙述ansible的工作原理 工作原理 xff1a ansible是基于Python开发 xff0c 集合众多运维工具的优势 xff0c 实现批量的部署操作 xff0c ansible是基于模块化 xff0c 本身并没有部署能力 x
  • pip 安装命令 及 配置Path路径

    pip 不是内部或外部命令 也不是可运行的程序 或批处理文件 pip 安装命令 及 配置环境变量 numpy 输入pip install numpy 时 xff0c 提示 以numpy 为例 pip 不是内部或外部命令 也不是可运行的程序
  • 1-python工厂模式

    文章目录 工厂模式定义 xff1a 它的优点 xff1a 可以有如下三种实现方式1 简单工厂模式2 工厂方法模式3 抽象工厂模式总结 工厂模式定义 xff1a 在面向对象编程中 xff0c 术语 工厂 表示一个负责创建替他类型对象的类 通常
  • Facebook_Pop的使用指北

    背景 最近公司有了一个创新项目 xff0c 就是在视频视图之上添加一层视图 xff0c 视图设计涉及到了复杂的控件动画 xff0c 会根据视频的播放 xff0c 显示一些控件 xff0c 控件有位移 缩放 旋转 shake等动画 在网上调研

随机推荐

  • iOS Jenkins自动化打包 上传fir、蒲公英、邮件、钉钉提醒

    一 环境配置 注意 xff0c 本文章是以Jenkins2 263 4为例 1 首先安装Java环境 xff1a 官网下载地址 2 安装Jenkins 建议下载Jenkins 2 263 4版本 xff0c 因为最新版本存在login ke
  • iOS11 WKWebview App Crash闪退

    最近项目在iOS11 0 3 iOS11 1 2 iOS11 2 1 iOS 11 2 2 iOS11 2 6上面莫名其妙会崩溃 xff0c 本以为是block或者是设置User Agent导致的 xff0c 最后定位是Request设置u
  • iOS判断是否开启代理,防止Charles抓包

    直接检查是否设置了代理即可 BOOL checkProxySetting NSDictionary proxySettings 61 bridgeNSDictionary CFNetworkCopySystemProxySettings N
  • iOS 已有项目利用Pod集成RN

    一 背景 对于已经存在的iOS项目 xff0c 以模块化引入 xff0c OC与RN混编怎么做呢 xff1f 我们可以利用cocopods来集成 xff0c 直接使用pod install就可以让其他同事也快速集成 由于RN用npx rea
  • 使用信号量使AFNetworking异步变同步(dispatch_semaphore_t)

    背景 当H5调用OC的时候 xff0c 默认是在主线程的 xff0c 如果H5调用后 xff0c 需要原生返回数据 xff0c 而原生获取数据又是个耗时的异步操作就会有问题 xff0c 比如OC是一个网络请求 xff0c 那就需要等原生请求
  • Alice 与 Bob 的游戏 (概率DP)

    题目描述 Alice 和 Bob 两个人正在玩一个游戏 xff0c 游戏有很多种任务 xff0c 难度为 p 的任务 xff08 p是正整数 xff09 xff0c 有 1 2 p 的概率完成并得到 2 p 1 分 xff0c 如果完成不了
  • windows搭建WINS服务

    文章目录 SDCserver WINS 1 安装WINS并配置为辅助WINS 2 DCserver为主要的WINS服务器 3 定期复制主WINS服务器的记录 4 DCserver离线后 自动切换为辅助服务器 SDCserver设备上 提示
  • iOS 内存管理

    内存管理 1 内存布局 bss xff1a 未初始化的全局变量 静态变量等data xff1a 已初始化的全局变量 静态变量等text xff1a 程序代码 内存布局 2 内存管理方案 TaggedPointer xff1a 对于小对象NS
  • isKindOfClass和isMemberOfClass

    BOOL isKindOfClass Class aClass BOOL isMemberOfClass Class aClass 我们来看看这两个方法有什么不同 xff0c 首先看看问题 BOOL res1 61 id NSObject
  • AVAudioRecorder stop崩溃 在iOS13系统上

    iOS15和iOS16都正常 xff0c 但是测试反馈在iOS13的系统上 xff0c AVAudioRecorder的实例对象调用stop方法会崩溃 xff0c 并且debug不到任何信息 原因是由于AVAudioRecorder的实例对
  • 【C++】输入优化(快读)

    快速读入 xff0c 简称快读 xff0c 比cin printf 等都快 void类型的快读 span class token macro property span class token directive keyword inclu
  • 【LaTeX】LaTeX入门

    文章目录 简介文章结构基本要素处理问题添加文档标题章节创建标签生成目录 xff08 TOC xff09 文字处理中文字体支持字体效果彩色字体字体大小段落缩进列表注释和空格特殊字符 表格图表公式插入公式数学符号上标和下标分数根号求和与积分希腊
  • C++中string的拼接

    字符拼接可以采用的方法 xff1a 1 多个字串拼接时用 43 操作符 1 xff09 代码 xff1a 如果不加红色部分的代码 xff0c 则需要采用 sntprintf代替sntprintf include lt iostream gt
  • LINUX 新挂载的磁盘(sdb,sdc)进行扩容

    1 在虚拟机上增加磁盘空间 xff0c 例如之前50G xff0c 增加到100G 2 fdisk l 查看磁盘容量是否变化 可以看出我们只用了一半的扇区 xff0c 也就是50G 3 df hl 查看现在的挂载情况 目前文件系统只有50G
  • VS各个版本对应的C++版本一览表(持续更新,最新为VS2022)

    文章目录 1 VS各版本与MSVC对照表2 GCC版本与C 43 43 支持情况表3 VS版本与C 43 43 支持情况表4 C 与 NET版本与C 43 43 支持情况表5 引用 官网地址 xff1a Visual Studio官网地址
  • 经典算法(5)- 用二进制方法实现扩展的最大公约数(Extended GCD)

    二进制方法中 xff0c 只需要移位 xff08 lt lt 和 gt gt xff09 和加减操作 xff08 43 和 xff09 xff0c 不像欧几里德算法中需要乘法和除法运算 虽然算法效率更高 xff0c 但是程序的可读性和可维护
  • shell-位置参数

    介绍 当我们执行一个shell时 xff0c 如果希望获取到命令行的参数信息 xff0c 就可以使用到位置参数变量 比如 xff1a myshell sh 100 200 这个就是一个执行shell的命令行 xff0c 获取到位置参数后 x
  • 多用户conda环境创建报错NotWritableError: The current user does not have write permissions to a required path.

    实验室最近来了一批服务器 xff0c 多个人共用一个3090 xff0c conda环境是全局安装 xff0c conda的安装目录是归属到anaconda的用户组 归属到anaconda的用户都能创建condah环境 今天在创建环境是报错
  • java自学之路

    JAVA自学之路 一 学会选择 为了就业 xff0c 不少同学参加各种各样的培训 决心做软件的 xff0c 大多数人选的是java xff0c 或是 net xff0c 也有一些选择了手机 嵌入式 游戏 3G 测试等 那么究竟应该选择什么方
  • 项目中常见的错误

    项目中遇到的错误 c9bcf64c sql错误 找不到列 Unknown column 39 fillMen 39 in 39 field list 39 2 列名在sql语句中写了2次 Column 39 fillMan 39 speci