Struts1详解:<html:errors/>标签与MVC设计模式
需积分: 9 72 浏览量
更新于2024-07-13
收藏 174KB PPT 举报
本文档主要介绍了Java EE中的Struts框架,特别是`<html:errors/>`标签的使用,以及Struts的基本概念、配置、标签库和国际化应用。
Struts是Apache Software Foundation发起的一个开源项目,它是一个基于MVC设计模式的Java Web开发框架。在Struts框架中,MVC模式的各个组件包括:
1. Model组件:通常由JavaBean实现,包含了业务逻辑和数据。JavaBean有对应的属性和set/get方法,用于操作数据。
2. View组件:主要由JSP页面构成,负责展示信息给用户。View与用户交互,并通过Formbean传递和验证数据。
3. Controller组件:ActionServlet是Struts中的控制器,它接收用户的请求,调用相应的Action进行处理。Action执行完业务逻辑后,Controller会决定展示哪个View给用户。
`<html:errors/>`标签在Struts中用于在JSP页面上显示应用程序的错误信息。当表单提交过程中出现验证错误或其他错误时,Struts会将这些错误存储在一个集合中,`<html:errors/>`标签可以自动遍历这个集合,将所有错误信息以适当的形式显示在页面上,帮助开发者和用户更好地识别和解决问题。
Struts框架的配置通常通过`struts-config.xml`文件完成,该文件定义了ActionServlet、Action类、FormBeans、数据源以及URL映射等核心配置,是Struts应用的核心配置文件。
除了基本的MVC组件,Struts还提供了丰富的标签库,例如`<html:form>`, `<html:text>`, `<html:submit>`等,这些标签简化了JSP页面的编写,提高了代码的可维护性和可读性。
此外,Struts支持应用的国际化(i18n),允许开发者为不同的语言和地区提供本地化的用户界面。这通常通过定义资源包(Resource Bundle)来实现,资源包中包含各种语言的字符串和消息,框架会根据用户的偏好自动选择合适的语言版本。
总结来说,Struts是一个强大的Java Web开发工具,它简化了MVC模式的实现,提供了错误处理和国际化支持,通过配置文件和标签库,使得开发更高效且易于维护。`<html:errors/>`标签是其错误处理机制的一部分,有助于提高用户体验和开发效率。
2010-11-30 上传
2007-05-12 上传
2010-11-01 上传
2023-06-28 上传
2023-07-14 上传
function generateReport() {
try {
var getUrl = window.location;
var baseUrl = getUrl.protocol + "//" + getUrl.host + "/";
var url = baseUrl + 'polarion/ImpactAnalysisTree/ImpactAnalysisTree?projectId=' + projectId;
var parameters = "";
var Id = false;
var title = false;
var workItemId = document.forms["tracegraph"]["itemId"];
if (workItemId != null) {
if (!workItemId.value.trim().length == 0) {
parameters = '&op=search&workItemId=' + workItemId.value;
Id = true;
}
}
if (!Id) {
$(".widget-errors").text("Enter a valid Work Item ID /Title to generate traceability report.").show();
return false;
}
// AJAX 异步请求
$.ajax({
url: url + parameters,
method: 'POST',
success: function(response) {
Data = JSON.parse(response);
},
error: function(error) {
console.log(error);
alert(error);
}
});
} catch (e) {
console.log(e);
alert(e);
}
return false;
}
根据返回的值重新渲染下面代码
<FORM id="tracegraph">
<form name="tracegraph">
Work Item ID
<input id="itemId" type="text" name="itemId" autocomplete="off"
placeholder="Work Item ID" style="width: 225px;">
</form>
Work Item ID |
<input id="itemId" type="text" name="itemId" autocomplete="off"
placeholder="Work Item ID" style="width: 225px;">
|
<button onclick="generateReport()" class="reportbutton" style="margin-left: 18px;" VALIGN=MIDDLE ALIGN=CENTER> Display Report</button> |
2023-07-14 上传
2023-06-28 上传
2023-06-28 上传
這是前端代碼,我需要修改error這個數據表的STATUS這一列數據
<!DOCTYPE html>
<html>
<head>
<title>Error Repair</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
</style>
</head>
<body>
Error Repair
LINE | SN | MO | MODEL | ITEM | TESTTIME | DATETIME | FACTORY | STATUS | REMARK | USERNAME | HOURS_DIFF |
---|---|---|---|---|---|---|---|---|---|---|---|
{{ error['LINE'] }} | {{ error['SN'] }} | {{ error['MO'] }} | {{ error['MODEL'] }} | {{ error['ITEM'] }} | {{ error['TESTTIME'] }} | {{ error['DATETIME'] }} | {{ error['FACTORY'] }} | {{ error['STATUS'] }} | {{ error['REMARK'] }} | {{ error['USERNAME'] }} | {{ error['HOURS_DIFF'] }} |
2023-07-15 上传
2023-07-23 上传
顾阑
- 粉丝: 15
- 资源: 2万+
最新资源
- JDK 17 Linux版本压缩包解压与安装指南
- C++/Qt飞行模拟器教员控制台系统源码发布
- TensorFlow深度学习实践:CNN在MNIST数据集上的应用
- 鸿蒙驱动HCIA资料整理-培训教材与开发者指南
- 凯撒Java版SaaS OA协同办公软件v2.0特性解析
- AutoCAD二次开发中文指南下载 - C#编程深入解析
- C语言冒泡排序算法实现详解
- Pointofix截屏:轻松实现高效截图体验
- Matlab实现SVM数据分类与预测教程
- 基于JSP+SQL的网站流量统计管理系统设计与实现
- C语言实现删除字符中重复项的方法与技巧
- e-sqlcipher.dll动态链接库的作用与应用
- 浙江工业大学自考网站开发与继续教育官网模板设计
- STM32 103C8T6 OLED 显示程序实现指南
- 高效压缩技术:删除重复字符压缩包
- JSP+SQL智能交通管理系统:违章处理与交通效率提升