1.hibernate的配置文件的放置位置。位置放错了会导致报错,说找不到配置文件。
hibernate.cfg.xml一般放在src根目录下
2. hibernate.cfg.xml配置文件中的mapping标签中的resource属性的值一般对应的是domain对象的映射文件*.hbm.xml,注意前面的包名直接用‘/’分隔开,否则会报错。之前用‘.’进行分隔时报错:resource: org.hibernate.tutorial.domain.Event.hbm.xml not found
3. 为什么需要实现序列化?
当你需要将对象的状态保存到文件中或通过网络进行传输时,需要将对象转换成字节序列,这就是序列化。因为网络设施和硬盘等硬件只能识别位、字节形式的数据,不能识别Java对象,通过序列化可以把Java对象转换成字节数据在网络上传输和存储。
4.Explain Struts work Flow?
1) A request comes in from a Java Server Page into the ActionServlet.
2) The ActionServlet having already read the struts-config.xml file, knows which form bean relates to this JSP, and delegates work to the validate method of that form bean.
3) The form bean performs the validate method to determine if all required fields have been entered, and performs whatever other types of field validations that need to be performed.
4) If any required field has not been entered, or any field does not pass validation, the form bean generates ActionErrors, and after checking all fields returns back to the ActionServlet.
5) The ActionServlet checks the ActionErrors that were returned from the form beans validate method to determine if any errors have occurred. If errors have occurred, it returns to the originating JSP displaying the appropriate errors.
6) If no errors occurred in the validate method of the form bean, the ActionServlet passes control to the appropriate Action class.
7) The Action class performs any necessary business logic, and then forwards to the next appropriate action (probably another JSP).
5.If you want to actually read the Struts 2 tag TLD file, you'll find it in the META-INF folder of the Struts 2 core jar.
6. Struts2中包级属性文件(package level properties)放在WEB-INF -> classes文件下,在myeclipse中要在navigator视图下才能看到,或者直接到项目文件夹下的classes目录中添加包级属性文件。
7. MyEclipse中给引用的JAR包添加源码。右击JAR包,选择Properties,在弹出的对话框中点击Java Source Attarchment,然后选定源文件的路径加载源码。
MyEclipse中给引用的JAR包添加API文档。右击JAR包,选择Properties,在弹出的对话框中点击Javadoc Location,然后选定源文件的路径加载API文档。
8. 让MyEclipse在编辑xml文件时提供提示功能。Window -> Properties -> MyEclipse -> Files and Editors -> XML -> XML Catalog,点击Add 按钮,把对应key和location填上,
Key Type选择URI。
![]()
![]()
9. Struts2中进行单元测试时,需引入如下几个JAR包
![]()