1.No getter method for property name problem(struts)
有一种可能是Bean没有写相应的get方法,例如变量userName的get方法是getUserName;
还有就是这个Bean为空;
2. MyEclipse的自动添加struts和hibernate功能不能返回,请注意!
所以我先使用MyEclipse导入struts和hibernate,然后将它们的jar导入到另外一个新建的工程,这是我就不需要Myeclipse来给我管理依赖了。
3 .在增加对struts taglib支持时,请将对应的tld文件追加到web.xml文件中去:
例如:
http://struts.apache.org/tags-bean
/WEB-INF/struts-bean.tld
4. 如果出错说某个tag在tld文件中没有,则说明自己在jsp文件中使用的tag和使用的struts taglib版本不一致
例如:在struts1.1中的html:locale,在struts1.2中改为html:lang
5. struts tag中可以使用scriptlets,但是在scriptlets中不能使用struts tag。
Any Struts tag will work only if you place it directly in the JSP, not if you
generate it through a scriptlet. To understand why it won’t work to generate
it in a scriptlet.
JSP life cycle:
- The JSP interpreter reads the JSP file, including any custom tags such as Struts tags and converts everything to Java source code
- It then compiles it into a class file
- It executes the code, rendering a response in plain HTML and sending it back to the browser.
- It is only at this point that the scriptlet code you inserted gets executed. It is now too late in the cycle to insert any custom tags, since they’ve already been interpreted by this point.
6. it is illegal according to JSP specification to nest one tag within
another as an attribute.
There are two options:
1) You evaluate bean:write and then substitute it into html:text.
2) Use Struts-EL tags. They let you use expression language to get a bean
value and substitute it in another tag.
Unless you have a system wide requirement to do this, I suggest you stick to
the first option.
7.Explain the scope of JSP objects.
Scope of JSP objects:
The availability of a JSP object for use from a particular place of the
application is defined as the scope of that JSP object.
Every object created in a JSP page will have a scope. Object scope in JSP is
segregated into four parts and they are page, request, session and
application.
- page
‘page’ scope means, the JSP object can be accessed only from within the same
page where it was created. The default scope for JSP objects created using
jsp:useBean tag is page. JSP implicit objects out, exception, response,
pageContext, config and page have ‘page’ scope.
- request
A JSP object created using the ‘request’ scope can be accessed from any pages
that serves that request. More than one page can serve a single request. The
JSP object will be bound to the request object. Implicit object request has
the ‘request’ scope.
- session
’session’ scope means, the JSP object is accessible from pages that belong to
the same session from where it was created. The JSP object that is created
using the session scope is bound to the session object. Implicit object
session has the ’session’ scope.
- application
A JSP object created using the ‘application’ scope can be accessed from any
pages across the application. The JSP
object is bound to the application object. Implicit object application has the
‘application’ scope.
8. Cannot find bean under name org.apache.struts.taglib.html.BEAN[转]
试图在Struts的form标记外使用form的子元素
不经意使用的无主体的标记,如web服务器解析时当作一个无主体的标记,随后使用的标记都被认为是在这个标记之外的
还有就是在使用taglib引入HTML标记库时,你使用的prefix的值不是html
property必须和所要提交的action对应的formbean中的某个属性相匹配(必须有一个formbean)
要使用标签,外层必须使用标签,不能使用html的
9.注意使用相对路径,比如说..或者.什么的。不要使用绝对路径。
一般来说404,提示说找不到资源,大部分就是路径写的不对。
10.今天使用jdbc连接数据库取得所有符合条件的数据库名字,然后根据数据库名动态生成各自对应的SessionFactory,
但是在画面上不同的叶子上进行转移切换不同数据库取得不同数据库的数据时,总是从业个特定的数据库中去数据。 最后的原因是在hibernate
的mapping文件中使用了catalog=”数据库名”,所以它总是连接到该数据库,将它删除回复正常。
11.Servlets are modules of Java code that run in a server application (hence
the name “Servlets”, similar to “Applets” on the client side) to answer client
requests. Servlets are not tied to a specific client-server protocol but they
are most commonly used with HTTP and the word “Servlet” is often used in the
meaning of “HTTP Servlet”.
ref:
http://www.novocode.com/doc/servlet-essentials/chapter1.html
http://www.roseindia.net/servlets/what-is-servlets.shtml
http://en.wikipedia.org/wiki/Servlet
JSP pages are high level extension of servlet and it enable the developers
to embed java code in html pages. JSP files are finally compiled into a
servlet by the JSP engine. Compiled servlet is used by the engine to serve the
requests.
javax.servlet.jsp package defines two interfaces:
These interfaces defines the three methods for the compiled JSP page. These
methods are:
- jspInit()
- jspDestroy()
- _jspService(HttpServletRequest request,HttpServletResponse response)
In the compiled JSP file these methods are present. Programmer can define
jspInit() and jspDestroy() methods, but the _jspService(HttpServletRequest
request,HttpServletResponse response) method is generated by the JSP engine.
ref:
http://www.roseindia.net/jsp/jsparchitecture.shtml
http://en.wikipedia.org/wiki/JavaServer_Pages
http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html
Tomcat implements the Servlet X.X and JSP X.X specifications
please visite this website: http://en.wikipedia.org/wiki/Apache_Tomcat
JSTL:
http://www.ibm.com/developerworks/views/java/libraryview.jsp?search_by=JSTL+primer
12.Adobe
Used Flash and the Flex framework to create applications
Flash Player 9 and AIR are the runtimes for browser-based and desktop-based
applications.