posts - 61,  comments - 2033,  trackbacks - 0
刚刚碰到的问题—— <html:text name="userForm" property="user.userAccount" styleClass="myInput" readOnly="true" /> 有错吗? 晕哦,就是错了,得把readOnly="true"改为readonly="true",可是在javasript下,用函数去指定true或者false,O就必须大写…… 所以就去找了以下一篇。

转自: 落叶空叹飘花翎 http://www.itpub.net/336395,1.html

Java 开发中遇到的乱码问题

若想明白jsp开发过程中为什么会产生中文乱码,我们先来看看unicode编码。
Unicode (统一码)顾名思义是一个将世界上各种文字统一在一起的东东。由美国各大电脑厂商组成的Unicode策进会来推动。目的,推广一个世界通用的编码体制,惊世界上所有常用的文字都涵盖进去,从而减少个电脑商开发国外市场遇到的问题。
为了将成千上万的文字统统收集到一个共同的编码机制下,在兼顾经济的原则下,不管是东方还是西方文字,每个字在Unicode中一律以两个Bytes来表示,这样至少有2的16次方65536种不同的组合,足以应付目前绝大多数场合的需要。
基本上,计算机只是处理数字。它们指定一个数字,来储存字母或其他字符。在创造Unicode之前,有数百种指定这些数字的编码系统。没有一个编码可以包含足够的字符:例如,单单欧州共同体就需要好几种不同的编码来包括所有的语言。即使是单一种语言,例如英语,也没有哪一个编码可以适用于所有的字母,标点符号,和常用的技术符号。
这些编码系统也会互相冲突。也就是说,两种编码可能使用相同的数字代表两个不同的字符,或使用不同的数字代表相同的字符。任何一台特定的计算机(特别是服务器)都需要支持许多不同的编码,但是,不论什么时候数据通过不同的编码或平台之间,那些数据总会有损坏的危险。
Unicode给每个字符提供了一个唯一的数字,不论是什么平台,不论是什么程序,不论什么语言。Unicode标准已经被这些工业界的领导们所采用,例如:Apple, HP, IBM, JustSystem, Microsoft, Oracle, SAP, Sun, Sybase, Unisys和其它许多公司。最新的标准都需要Unicode,例如XML, Java, ECMAScript (JavaScript), LDAP, CORBA 3.0, WML等等,并且,Unicode是实现ISO/IEC 10646的正规方式。许多操作系统,所有最新的浏览器和许多其他产品都支持它。Unicode标准的出现和支持它工具的存在,是近来全球软件技术最重要的发展趋势。
将Unicode与客户服务器或多层应用程序和网站结合,比使用传统字符集节省费用。Unicode使单一软件产品或单一网站能够贯穿多个平台,语言和国家,而不需要重建。它可将数据传输到许多不同的系统,而无损坏。
在与Unicode相关的各技术文件中,经常会看到ISO 10646和UCS这两个名词。
ISO是位于瑞士的国际标准局的缩写。
UCS为ISO颁布的第10646号标准 Universal Character Set,就是世界通用字符集。
UCS通用字符集采用4个Bytes来编码,将世界上所有的官用和商用编码大小通吃,一网打尽。Unicode自1991年便和ISO的UCS小组密切配合,让Unicode和ISO 10646保持一致。因此Unicode 自2.0版开始,便和 ISO 10646-1使用相同的编码。
康熙字典中的汉字有4万7千,如果再加上里面没有的简体字,和不同写法的日文字,那么 Unicode6万多的分配空间,光用来分配汉字就显得捉禁见昼,更别说什么泰文,阿拉伯等其他文字了。针对这个问题Unicode和UCS采用了[中日韩文整合](CJK Unification)的解决方案,把中日韩笔画详尽的汉字用同一个单码表示。
经过[中日韩文整合]的Unicode称为统汉字Unihan。
完整的Unicode4.0版可由http://www.unicode.org/Public/UNIDATA/Unihan.txt 下载。

UTF (Unicode/UCS Transformation Format),Unicode推荐使用UTF-8和UTF-16两种格式其中8和16指的是Bits数而不是Bytes数。
UTF-16基本就是Unicode双字节的实现,加上一个应付未来需要的扩充编码机制(很少用)
UTF-8 是一种不等幅的编码方式,英数字(Ascii字码)保持原状,完全不受影响(因此不需要做转换),而其他汉字资料须透过程序来转换,会[变胖],因为每个字需要额外一个或两个Bytes来编码。
UCS字符集中,有UCS-2和UCS-4等编码方式其中的2和4指的是bytes数,对应UTF-8和UTF-16.
UCS-2基本和Unicode双byte 编码差不多
UCS-4四 byte编码表示一个字,在每个 UCS-2前面加上两个空白的Byte,便可得到对应的 UCS-4。

Unicode的空间分配:
以下Unicode区位码均以16进制表示
Unicode的前256个字符和ISO-8859-1(西欧字母)完全相同,其中前半段就是Ascii(u+0000到u+00FF)。每个ISO-8859-1码前面补上一个空byte(0x00)后才是相应的Unicode码。
和我们切身相关的Unihan主要分布在u+3400到u+F9FFF之间,GB2312和BIG5主要分布在u+4E00到U+9FFF之间。

UTF-8的编码原理和特性:
知道了西欧字符和汉字在Unicode中的位置后,来看看UTF-8

U+0000~U+007E 1 _ _ _ _ _ _ _ (7bits)
U+0080~U+07FF 1 1 0_ _ _ _ _ 1 0_ _ _ _ _ _ (11bits)
U+0800~U+FFFF 1 1 1 0 _ _ _ _ 1 0 _ _ _ _ _ _ 1 0 _ _ _ _ _ _ (16bits)
看一看Unicode三种格式提出自由的bits(下划线空位)是否足以用来代表区位中各Unicode码,刚好够用。
那么当程序处理UTF-8编码文件时,如何得知一个字符的疆界落在哪里?还有到底他是以三种形式那一中出现呢?
每个以UTF-8编码的字符,不管是以一、二、三个bytes出现,第一个byte前端都清楚地标示了该字符的byte总数。如110种有两个1,代表这种字符是以第二种方式出现,由两个bytes组成。而1110有三个1,表示这种字符一点种方式出现,由三个字节组成。
每个多重byte的UTF-8编码有一个共同的通性,即其中的第二个第三个byte, 一律以10两个bits开头。由于其中的最高位总设成1,可以很容易和那些在UTF-8中只用一个Byte的ASCII字元区分开来,方便侦错。
因为上述设计特点,UTF-8和Unicode之间,可以很容易做双向自由转换,而不会丢失任何资料。

解决办法:乱码问题在 NT操作系统我没怎么碰到过,但是在UNIX 或LINUX系统上出现的比较多
由于操作系统和使用环境不一样,产生乱码的方式也不一样,但是如果掌握了上面的Unicode 编码原理,自己仔细分析一下,很多问题便可迎刃而解。
下面看看几个常见的例子。
1. 如果一些网站服务器例如Tomcat 如果遇到中文乱码问题,可以修改conf目录下的server.xml
<Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100" debug="0"connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="GBK"/>
URIENcoding 设成GBK或GB2312
2. 表单中或传递字符串:本来输入的汉字是正常的,但是提交后再显示出来是乱码,因为提交的一般是 ISO8859编码,所以显示的时候要转成GB2312编码:

String S=new String(rs.getString("news").getBytes("gb2312"),"ISO8859_1");
//rs为待转换的字符串
然后使用S字符串的值就可以了
3. 有的服务器端的语言环境如果设成简体中文的也可以解决此类问题
4. 插入数据库中的字符是乱码
看看数据库中支持的是何种编码方式,用类似2中的方式作一下转换即可。
5. 总之,用jsp开发,碰到乱码,你得分析是读的时候发生乱码,还是写的时候发生乱码,用2中的转换,基本就能解决问题,有些时候写的时候做一次转换,例如:
String S=new String(rs.getString("news").getBytes("gb2312"),"ISO8859_1");
//读的时候在转换回来
String S=new String(rs.getString("news").getBytes("ISO8859_1"),"GB2312");
或者把ISO8859-1和GB2312 的位置换一下,自己多试试,就能找到解决问题的办法。

Java_struts 入门快速手册

----by omencathay
Struts
简介
1、 Struts基于MVC模式 Model(Bean) ,View(jsp文件), Control (Action类,ActionForm类)
2、 开发准备
struts http://jakarta.apache.org/struts
jdk1.2版本以上 http://java.sun.com/j2se
Xerces XML parser http://xml.apache.org/xerces-j
下载struts后,解压zip文件到一个临时目录;然后拷贝struts.jar, jakarta-oro.jar, jdbc2_0-stdext.jar和common*.jar文件到你所应用struts的WEB-INF/lib目录下;拷贝struts*.tld文件和*.dtd文件到WEB-INF目录下,确定该才提到的所有的jar包都在web应用服务器的 classpath环境变量上设置。
3、 配置 (两个xml文件:web.xml, struts-config.xml)
配置web.xml,第一件事情就是注册组件action servlet,<servlet> .. </servlet>标签封装了整个struts 框架的应用程序
<!-- Action Servlet Configuration -->
1 <servlet>
2 <servlet-name>action</servlet-name>
3 <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
4 <init-param>
5 <param-name>application</param-name>
6 <param-value>myApp.properties.ApplicationResources</param-value>
7 </init-param>
8 <init-param>
9 <param-name>config</param-name>
10 <param-value>/WEB-INF/struts-config.xml</param-value>
11 </init-param>
12 </servlet>
13 <!-- Action Servlet Mapping -->
14 <servlet-mapping>
15 <servlet-name>action</servlet-name>
16 <url-pattern>*.do</url-pattern>
17 </servlet-mapping>
18 <!-- Application Tag Library Descriptor -->
19 <taglib>
20 <taglib-uri>/WEB-INF/lib/app.tld</taglib-uri>
21 <taglib-location>/WEB-INF/lib/app.tld</taglib-location>
22 </taglib>
23 <!-- Struts Tag Library Descriptor -->
24 <taglib>
25 <taglib-uri>/WEB-INF/lib/struts.tld</taglib-uri>
26 <taglib-location>/WEB-INF/lib/struts.tld</taglib-location>
27 </taglib>
28 <!-- Struts Tag Library Descriptors -->
29 <taglib>
30 <taglib-uri>/WEB-INF/lib/struts-bean.tld</taglib-uri>
31 <taglib-location>/WEB-INF/lib/struts-bean.tld</taglib-location>
32 </taglib>
33 <taglib>
34 <taglib-uri>/WEB-INF/lib/struts-form.tld</taglib-uri>
35 <taglib-location>/WEB-INF/lib/struts-form.tld</taglib-location>
36 </taglib>
37 <taglib>
38 <taglib-uri>/WEB-INF/lib/struts-logic.tld</taglib-uri>
39 <taglib-location>/WEB-INF/lib/struts-logic.tld</taglib-location>
40 </taglib>
41 <taglib>
42 <taglib-uri>/WEB-INF/lib/struts-template.tld</taglib-uri>
43 <taglib-location>/WEB-INF/lib/struts-template.tld</taglib-location>
44 </taglib>

struts-config.xml文件
1 <?xml version="1.0" encoding="ISO-8859-1" ?>
2 <!DOCTYPE struts-config PUBLIC
3 "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
4 "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
5 <struts-config>
6 <data-sources>
7 <data-source key = "myDatabase">
8 <set-property property="autoCommit" value="false"/>
9
10 <set-property property="description"
11 value=" Login Validation Database"/>
12 <set-property property="driverClass"
13 value="org.postgresql.Driver"/>
14 <set-property property="maxCount"
15 value="4"/>
16 <set-property property="minCount"
17 value="2"/>
18 <set-property property="user"
19 value="myusername"/>
20 <set-property property="password"
21 value="mypassword"/>
22 <set-property property="url" value="jdbcostgresql://localhost/myAppDatabase"/>
23
24 </data-source>
25 </data-sources>
26 <!-- ========== Form Bean Definitions ========================== -->
27 <form-beans>
28 <!-- Logon form bean -->
29 <form-bean name="login"
30 type="myApp.FormBeans.LoginForm"/>
31 <!-- Order List -->
32 <form-bean name="orderlist"
33 type="myApp.FormBeans.OrderForm"/>
34 </form-beans>
35 <!-- ========== Global Forward Definitions ===================== -->
36 <global-forwards>
37 <forward name="login" path="/login.jsp"/>
38 </global-forwards>
39 <!-- ========== Action Mapping Definitions ===================== -->
40 <action-mappings>
41 <!-- Process a user logon -->
42 <action path="/login"
43 type="myApp.action.LoginExec"
44 name="login"
45 validate = "true"
46 scope="session"
47 input="/login.jsp">
48 <forward name="success" path="/secondpage.jsp"/>
49 <forward name="listorder" path="/orderlistentry.do"/>
50 <forward name="killSession" path="/SystemError.html"/>
51 </action>
52 <!-- Process a user logoff -->
53 <action path="/logout"
54 type="myApp.action.LogoutExec">
55 <forward name="success" path="/logout.jsp"/>
56 </action>
57 <!-- Process an order list -->
58 <action path="/orderlistentry"
59 type="myApp.action.OrderListExec"
60 name="orderlist"
61 scope="session"
62 input="/orderlistentry.jsp">
63 <forward name="success" path="/orderlistdisp.jsp"/>
64 <forward name="killSession" path="/SystemError.html"/>
65 <forward name="loginAgain" path="/login.jsp"/>
66 <forward name="selectSalesArea" path="/salesAreas.jsp"/>
67 </action>
68 </action-mappings>
69 </struts-config>

注:最重要的部分是action-mappings 部分
<action-mappings>
每个<action>元素定义了特定的功能与相关联的动作类, 大多数action元素至少包括以下三个部分。
Path-----应用程序映射的路径
Type-----需要的完整的包和类
Name-----action应用的<form-bean>元素的名称

<forward>标签告诉struts框架将要跳转到哪个jsp页面;
<data-sources>标签给出数据源属性;


4、 struts核心标签库示例
1. Html:form
属性:onsubmit

onsubmit属性得到的是:表单提交时的javaScript事件句柄
用法:
(1).
Onsubmit 和 html:submit配合使用,javaScript函数返回true或false

<html:form action=”” onsubmit=”return javaScriptFunction();”>

<html:submit onclick=” javaScriptFunction();”/>
配合使用
在javaScriptFunction(){
}中加入return true和return false
html:from 根据返回的true或者false决定是否提交
等同于
(2)。
使用Html:button 要在javaScript函数中加入form.submit();
<html:form action=””>
<html:button onclick=” javaScriptFunction();”/>
form.submit();决定表单的提交

2. Html:text
Html:text是输入框,可以修改数据做为property的值


如果要修改的属性在bean中有get\set方法,可以写为
<html:text name="listInfoFormBean" property="invoiceCode"/>

如果要修改的属性在某一个VO里,在VO里对这一属性有get\set方法,在bean里对这一VO有get\set方法,可以写为:
<html:text name="listInfoFormBean" property="tbInvStoresVO.invoiceCode"/>

3. Bean:write
Bean:write与html:text用法相似。只是bean:write输出的数据是readonly的

这一点可以在html:text中加入属性 readonly=”true”来实现

4. Html:select
<html:select property="invoicePurchaseCode" name=”beanname”>
<option value="0">----</option>
<option value="1">验旧供新</option>
<option value="2">交旧供新</option>
<option value="3">批量供应</option>
</html:select>
name::bean的名称。如果没有设置,将适用于这个内嵌表单相关的formbean的名字
property:表单提交是送回的请求参数的名字,也是用来确定哪个属性被选中的bean的属性的名字
value:用来表明需要被选中的选项

怎么生成一个select:
option.options = new(value, lablename)

5. logic:iterate
logic:iterate的两个用法
1. 在javaScript中初始化数组数据
//声明数组
var invoiceWordCodeArray = new Array();

//构造函数
function invoiceWordCode(invoiceCode,invoiceWordCode){
this.invoiceCode = invoiceCode;
this.invoiceWordCode = invoiceWordCode;
}

//初始化数据
<logic:iterate id="item2" name="listInfoFormBean" property="wordCodeList" indexId="i">
invoiceWordCodeArray[<bean:write name="i"/>] =
new invoiceWordCode(
'<bean:write name="item2" property="invoiceCode"/>',
'<bean:write name="item2" property="invoiceWordCode"/>');
</logic:iterate>

2.在页面上循环显示一个集合中的数据
<logic:iterate indexId="idx" id="sampleBean" name="sampleList">
<tr>
<td align="center" style="padding:1px 4px 0px 5px"></td><td width="150">
<bean:write property="id" name="sampleBean"/></td><td width="150">
<bean:write property="content" name="sampleBean"/></td><td width="150">
<bean:write property="creator" name="sampleBean"/></td>
</tr>
</logic-el:iterate>
id:页面作用域bean的名称,集合的别名
name:formbean的名字,它包含property
property:需要循环的集合的名字
logic:iterate:需要在formbean中对集合中的VO有get\set方法
indexed=”true”:每次重复完成后集合当前的索引

 

posted on 2006-01-07 22:10 鱼上游 阅读(4830) 评论(6)  编辑  收藏 所属分类: 爪哇风景欣赏


FeedBack:
# re: jsp-struts 常见问题集锦 --
2006-01-17 10:59 | errorfun
没错,要搞定JSP的乱码问题就得搞懂编码,当时我和了一个月的时间去研究编码,有些心得.

首先,乱码问题的一个主要原因是TOMCAT,TOMCAT的核心编码用的是ISO-8859-1(默认),所以你在页面中怎么处理SETREQUESTENCODING,SETRESPONSEENCODING都无效,乱码依旧,你必须在SERVER.XML文件中更改下TOMCAT的编码,如本文提到的URIENCODING="GBK".当然你的页面还要设置ENCODING还有SETRESPONSEENCODING(此时才能生效),而像本文中提到的
String S=new String(rs.getString("news").getBytes("gb2312"),"ISO8859_1");
是为下下策,你既然设了URIENCODING,就没必要用这方法了,这方法是在没设的情况下用的.  回复  更多评论
  
# re: jsp-struts 常见问题集锦 --
2006-01-18 13:35 | 胡子鱼
nod,只要页面的字符设定一至就行。  回复  更多评论
  
# re: jsp-struts 常见问题集锦 --
2006-07-11 11:28 | 胡子鱼
<html:text name="inquiryForm" property="expectedReplyDateStr" size="20" readonly="true"/> 如果size="20" ,不加引号,会引起异常。  回复  更多评论
  
# re: jsp-struts 常见问题集锦 --
2006-07-12 15:39 | 胡子鱼
转自:
http://www.matrix.org.cn/thread.shtml?topicId=2624&forumId=22

Struts常见错误及原因
Common Struts Errors and Causes

This page contains errors and exceptions commonly encountered during web application development using Struts. Along with the exception or error messages themselves, potential causes of these errors are often listed along with links to additional resources.
To find the error you&#39;re looking for, use your browser&#39;s Find or Search capability and input a few words that you are seeing in your error message.
Cannot retrieve mapping for action
错误信息 javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login
可能原因
lNo action defined in struts-config.xml to match that specified in the JSP&#39;s <html:form action="Login.do".
相关链接
No action instance for path /xxxx could be created
错误信息 No action instance for path /xxxx could be created
可能原因
lSpecial Note: Because so many different things can cause this error, it is recommended that you turn your error logging/debugging levels on your web server to a high level of verbosity to see the underlying problems in trying to instantiate the action class you have written and associated with the specified action xxxx through an action mapping in the struts-config.xml file.
lYour Action class specified in the struts-config.xml file under the class attribute of the action mapping for action xxxx cannot be found for a variety of reasons, including (but not limited to): ·Failure to place compiled .class file for the action in the classpath (needs to be under WEB-INF/classes with the appropriate directory structure underneath this that matches the package your Action class belongs to). ·Package spelling or hierarchy specified in your action class itself (using the package keyword) does not match the spelling or complete package hierachy specified for your action class in the class attribute of the action in struts-config.xml.
lAction class specified in the /xxxx action mapping in the struts-config.xml file (class attribute) does not extend (directly or indirectly) from the Action class. In other words, your custom Action class does not extend off the Struts-provided Action class or off of another class that eventually extends the Action class (such as DispatchAction.
lProblem in your classpath, such as web server not being able to find ApplicationResources.properties files in the WEB-INF/classes/ directory or specified subdirectory.
lProblem in struts-config.xml file with action mapping.
lProblem with data-sources.xml file.
相关链接
lApplication&#39;s Action classes does not extend Struts-provided Action class·
lPackage hierarchy/directory structure specified in struts-config.xml file differs from that hierarchy specified in the actual action class&#39;s file using the package keyword.http://www.mail-archive.com/struts-user@jakarta.apache.org/msg65874.html ·
lAction Mapping mistake in struts-config.xml:http://www.manning.com/ao/readforum.html?forum=siaao&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
可能原因
lNo getXXXX() method defined for form field with name XXXX
lThis can happen if the JSP/Struts developer forgets that the name of the get method will have the same spelling as the value supplied in the Struts tag&#39;s property attribute, but that case will be different and is based on JavaBean specification rules. For example, my form class should have a getUsername method if my Struts form-related tag has username as the value for its property attribute. Note the difference in case marked with emphasis on the letter "U."
相关链接
lCase can trip up the matching between get method&#39;s name and name specified in Struts taghttp://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=000163
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}
可能原因
lInstantiating 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.
lNot associating an Actionform-descended class with an action can also lead to this error.
Cannot find ActionMappings or ActionformBeans collection
错误信息 javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionformBeans collection
可能原因
lEither the <servlet> tags for the Struts action servlet or the <servlet-mapping> tags for the .do extension mapping or both not present in the web.xml file. I saw a case where the web.xml file had no elements other than the root element and so this error was occurring.
lTypos or spelling errors in the struts-config.xml can lead to this error message. For example, missing a slash ("/") on a closing tag can have this effect.
lAnother element that must be present in the web.xml file is the load-on-startup element. This can be either an empty tag or can have an integer specified that indicates the priority of executing the associated servlet. The higher the number in the load-on-startup tags, the lower its priority.
相关链接

NullPointerException at ... RequestUtils.forwardURL
错误信息 java.lang.NullPointerException at org.apache.struts.util.RequestUtils.forwardURL (RequestUtils.java:1223)
可能原因
lMissing path attribute in the forward subelement of the action element in struts-config.xml
相关链接
Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
错误信息 javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
可能原因
lTrying to use Struts form subelement tags outside of the Struts&#39; form tag.
相关链接
lUsing form subelements outside of a form tag http://forum.java.sun.com/thread.jsp?thread=337537&forum=4&message=1384153
Missing message for key xx.xx.xx
错误信息 javax.servlet.jsp.JspException: Missing message for key xx.xx.xx
可能原因
lThe key-value pair with specified key is not in ApplicationResources.properties file
lApplicationResources.properties file not in classpath (not in WEB-INF/classes directory in specified location)
相关链接
Cannot find message resources under key org.apache.struts.action.MESSAGE
错误信息 Cannot find message resources under key org.apache.struts.action.MESSAGE
可能原因
lExplicitly trying to use message resources that are not available (such as ApplicationResources.properties not available
lImplicitly 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)
lXML parser issues -- too many, too few, incorrect/incompatible versions
相关链接
lXML Parser Issues http://www.mail-archive.com/struts-user@jakarta.apache.org/msg15779.html

No input attribute for mapping path /loginAction
错误信息 No input attribute for mapping path /xxxxAction
可能原因
lNo 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.
相关链接
Strange Output Characters (页面乱码)
错误信息 Strange and seemingly random characters in HTML and on screen, but not in original JSP or servlet.
可能原因
lRegular HTML form tags intermixed incorrectly with Struts html:form tags.
HTML标签与Struts标签不正确的混合使用
lEncoding style used does not support characters used in page.
使用了JSP页面不支持的编码
相关链接
"Document contained no data" or no data rendered on page (空白页面)
错误信息
l"Document contained no data" in Netscape (在Netscape中显示“文件中无数据”)
lNo data rendered (completely empty) page in Microsoft Internet Explorer(在IE中为空白页面,无任何显示信息)
可能原因
lEmploying a descendent of the Action class that does not implement the perform() method while using the Struts 1.0 libraries. Struts 1.1 Action child classes started using execute() rather than perform(), but is backwards compatible and supports the perform() method. However, if you write an Action-descended class for Struts 1.1 with an execute() method and try to run it in Struts 1.0, you will get this "Document contained no data" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer.
l用Struts1.1写的应用在struts1.0环境中运行时,可能出现此问题。
相关链接


其它错误信息
编译JSP文件时出现错误:
java.lang.NullPointerException
error:org.apache.jasper.JasperException: Error compiling \JSPs\security\appUserCreate.jsp
可能原因:
JSP页面中的Struts标记有语法错误。
例如:<bean:message key=”button.submit”> 错误原因:右边的括号前缺少斜杠“/”
正确的为:<bean:message key=”button.submit”/>

不同语言资源文件中的Key不匹配。  回复  更多评论
  
# re: jsp-struts 常见问题集锦 --
2006-08-22 14:19 | 胡子鱼
log4J配置:转自javaeye

怕麻烦的话可以考虑放应用下的某一个目录下,整个Servlet,专门用来设置环境变量和读取log4j的配置文件 ,初始化Servlet的时候,应用程序的目录是固定的 ,
可以通过System.setProperty("webappHome",this.getServletContext().getRealPath(""));来设置当前应用的目录的绝对路径为java内部的环境变量,在log4j的配置文件里面用${webappHome}/WEB-INF/conf/log/Application.log 来配置该文件的绝对路径就可以了  回复  更多评论
  
# re: jsp-struts 常见问题集锦 --
2007-10-26 14:20 | freeman1984
可以用filter解决编码问题  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 
<2006年1月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(82)

随笔分类(59)

文章分类(21)

相册

收藏夹(40)

GoodSites

搜索

  •  

积分与排名

  • 积分 - 1263549
  • 排名 - 22

最新评论

阅读排行榜