根据xml生成xsd,然后根据xsd生成javabean

1 篇文章 0 订阅
1 篇文章 0 订阅
根据xml在线生成xsd:  http://www.xmlforasp.net/CodeBank/System_Xml_Schema/BuildSchema/BuildXMLSchema.aspx

根据xsd生成javabean: DOS命令,进入xsd所在的目录(bb为要生成的javabean所在的文件夹),xjc -p com.xasxt.spring.model ems.xsd -d bb
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是用javabean制作一个页面,页面的背景颜色以及文字的大小、字体和颜色可以根据用户的选择来实施的代码实现: 1. 创建一个JavaBean类,名为PageProperties,用于设置页面的属性。代码如下: ```java public class PageProperties { private String bgColor; private String fontColor; private String fontFamily; private int fontSize; public String getBgColor() { return bgColor; } public void setBgColor(String bgColor) { this.bgColor = bgColor; } public String getFontColor() { return fontColor; } public void setFontColor(String fontColor) { this.fontColor = fontColor; } public String getFontFamily() { return fontFamily; } public void setFontFamily(String fontFamily) { this.fontFamily = fontFamily; } public int getFontSize() { return fontSize; } public void setFontSize(int fontSize) { this.fontSize = fontSize; } } ``` 2. 创建一个JSP页面,名为index.jsp,用于展示用户选择的页面。代码如下: ```jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="bean" uri="/WEB-INF/tags/pageProperties.tld" %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Page Properties Example</title> <style> body { background-color: ${pageProperties:bgColor}; font-size: ${pageProperties:fontSize}px; font-family: ${pageProperties:fontFamily}; color: ${pageProperties:fontColor}; } </style> </head> <body> <h1>Page Properties Example</h1> <p>This is a sample text.</p> <form method="post" onsubmit="updatePageProperties(); return false;"> <label for="bgColor">Background Color:</label> <select name="bgColor" id="bgColor"> <option value="white">White</option> <option value="red">Red</option> <option value="green">Green</option> <option value="blue">Blue</option> </select> <br> <label for="fontColor">Font Color:</label> <select name="fontColor" id="fontColor"> <option value="black">Black</option> <option value="white">White</option> <option value="red">Red</option> <option value="green">Green</option> <option value="blue">Blue</option> </select> <br> <label for="fontFamily">Font Family:</label> <select name="fontFamily" id="fontFamily"> <option value="Arial">Arial</option> <option value="Times New Roman">Times New Roman</option> <option value="Verdana">Verdana</option> <option value="Courier New">Courier New</option> </select> <br> <label for="fontSize">Font Size:</label> <select name="fontSize" id="fontSize"> <option value="12">12</option> <option value="14">14</option> <option value="16">16</option> <option value="18">18</option> </select> <br> <input type="submit" value="Apply Changes"> </form> <script> function updatePageProperties() { var form = document.forms[0]; var bgColor = form.elements['bgColor'].value; var fontColor = form.elements['fontColor'].value; var fontFamily = form.elements['fontFamily'].value; var fontSize = form.elements['fontSize'].value; var data = 'bgColor=' + bgColor + '&fontColor=' + fontColor + '&fontFamily=' + fontFamily + '&fontSize=' + fontSize; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { window.location.reload(); } }; xhttp.open("POST", "update.jsp", true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.send(data); } </script> </body> </html> ``` 3. 创建一个JSP页面,名为update.jsp,用于更新用户选择的页面属性,并重定向到index.jsp页面。代码如下: ```jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*" %> <%@ page import="javax.servlet.http.*" %> <jsp:useBean id="pageProperties" class="PageProperties" scope="session" /> <% String bgColor = request.getParameter("bgColor"); String fontColor = request.getParameter("fontColor"); String fontFamily = request.getParameter("fontFamily"); int fontSize = Integer.parseInt(request.getParameter("fontSize")); pageProperties.setBgColor(bgColor); pageProperties.setFontColor(fontColor); pageProperties.setFontFamily(fontFamily); pageProperties.setFontSize(fontSize); response.sendRedirect("index.jsp"); %> ``` 4. 创建一个标签库文件,名为pageProperties.tld,用于定义自定义标签,以便在JSP页面中使用PageProperties类。代码如下: ```xml <?xml version="1.0" encoding="UTF-8"?> <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0"> <description>Page Properties Tag Library</description> <tlib-version>1.0</tlib-version> <short-name>pp</short-name> <uri>/WEB-INF/tags/pageProperties.tld</uri> <tag> <name>pageProperties</name> <tag-class>PageProperties</tag-class> <body-content>empty</body-content> <attribute> <name>bgColor</name> <required>false</required> <rtexprvalue>true</rtexprvalue> </attribute> <attribute> <name>fontColor</name> <required>false</required> <rtexprvalue>true</rtexprvalue> </attribute> <attribute> <name>fontFamily</name> <required>false</required> <rtexprvalue>true</rtexprvalue> </attribute> <attribute> <name>fontSize</name> <required>false</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> </taglib> ``` 5. 将以上代码保存到Web应用程序的相应目录下,然后在Web浏览器中访问index.jsp页面,即可看到一个带有下拉框的页面。选择下拉框中的选项,页面的背景颜色和字体属性就会相应地改变。 以上就是用javabean制作一个页面,页面的背景颜色以及文字的大小、字体和颜色可以根据用户的选择来实施的代码实现。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值