[英]How to display html elements defined in xml file on JSP page
I'm currently working on a web application where in I'm continuously adding new columns to the database tables for new projects. 我目前正在开发一个Web应用程序,在该应用程序中,我不断向新项目的数据库表中添加新列。 I don't want to keep any dependency on Java program to display new column details on JSP page hence I want to define each and every html element/components including attributes in the XML file and want to load them dynamically on the web page (JSP). 我不想保留对Java程序的任何依赖以在JSP页面上显示新的列详细信息,因此我想定义每个html元素/组件(包括XML文件中的属性),并希望将它们动态加载到Web页面上(JSP) )。 I know we can read below XML file using any Java XML parser but actual problem is while placing the html elements on the JSP page. 我知道我们可以使用任何Java XML解析器读取下面的XML文件,但实际的问题是在JSP页面上放置html元素时。
I'm using struts 2 framework. 我正在使用struts 2框架。
Sample XML file 样本XML文件
<?xml version= "1.0" encoding ="UTF-8"?>
<!DOCTYPE ROOTCOMPONENT [
<!ATTLIST COMPONENT
COMP_NAME CDATA #REQUIRED
COMP_TYPE CDATA #REQUIRED
LABLE CDATA #IMPLIED
SIZE CDATA #IMPLIED
TABLE_NAME CDATA #IMPLIED
COLUMN_NAME CDATA #IMPLIED
>
]>
<ROOTCOMPONENT >
<COMPONENT COMP_NAME="INPUT" COMP_TYPE="TEXT" LABLE="User Name" />
<COMPONENT COMP_NAME="INPUT" COMP_TYPE="PASSWORD" LABLE="Password"/>
</ROOTCOMPONENT>
Would it be possible? 这有没有可能? Does anyone knows how it can be achieved? 有谁知道如何实现? Any sample code snippet would be really helpful. 任何示例代码片段都将非常有用。
您可以使用XML标记库的“转换标记”在JSP页面中使用XSLT转换XML,而无需任何其他Java代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.