Archive for Struts

html:erros 怎用?

在Action或Form里生成errors:

在Action中使用:

若用<html:erros />则显示出所有的错误

文章出處:

http://www.cjsdn.net/post/view?bid=20&id=138667&sty=1&tpg=11&age=0


發表迴響

structs標籤範例: logic:notEmpty

Html代码
  1. <logic:notEmpty name=“element" property=“idbmqx">
  2. 内容
  3. </logic:notEmpty>
Java代码
  1. if(idbmqx!=null)
  2. {
  3. 内容
  4. }

文章出處:

http://heisetoufa.javaeye.com/blog/227347

發表迴響

Structs標籤使用舉例: logic

1.  logic:empty
该标签是用来判断是否为空的。如果为空,该标签体中嵌入的内容就会被处理。该标签用于以下情况:

1)当Java对象为null时;
2)当String对象为""时;
3)当java.util.Collection对象中的isEmpty()返回true时;
4)当java.util.Map对象中的isEmpty()返回true时。
eg.
<logic:empty   name="userList">

</logic:empty>
该句等同于:
if   (userList.isEmpty())   {

}

文章出處:

http://qsrock.javaeye.com/blog/145529

發表迴響

structs-config.xml Version

配置structs-config.xml 時, 一旦加上了 <plug-in>元素, 便會出錯

訊息類似:

Parse Error at line 15 column 68: Element type "plug-in" must be declared.

….

org.xml.sax.SAXParseException: The content of element type "struts-config" must match "(data-soures?,form-beans?,global-forwards?,action-mappings?)".

….

其實這主要是版本的問題.


正是你声明了才会报错,首先说这个错误的问题,因为你的配置文件头用的
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
所 以使用的是struts1.0的配置文件格式,你可以从http://jakarta.apache.org/struts/dtds/struts- config_1_0.dtd下载这个DTD看看里面不包含messeage-resources和plug-in的元素定义,另外从错误提示中也可以看 出来
org.xml.sax.SAXParseException: The content of element type "struts-config" must match "(data-soures?,form-beans?,global-forwards?,action-mappings?)".

解决办法一是去掉那两个元素,二是文档定义用比struts1.0更高版本的,例如
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
这个是struts1.2的,但也要保证你用的struts包也是1.2的

資料來源: http://www.javaresearch.org/forum/thread.jsp?column=20&thread=36528

發表迴響

Follow

Get every new post delivered to your Inbox.