演练5-5:Contoso大学校园管理系统5
Contoso University示例网站演示如何使用Entity Framework 5创建ASP.NET MVC 4应用程序。 Entity Framework有三种处理数据的方式: Database First , Model First , and Code First . 本指南使用代码优先。其它方式请查询资料。 示例程序是为Contoso University建立一个网站。功能包括:学生管理、课程创建、教师分配。 本系列指南逐步讲述如何实现这一网站程序。
如有问题,可在这些讨论区提问: ASP.NET Entity Framework forum, the Entity Framework and LINQ to Entities forum, or StackOverflow.com.
上一节完成了相关联数据的显示,本节将学习如何更新关联数据。大部分关联关系可通过更新相应的外键来完成。对于多对多关系,EF没有直接暴漏连接表,需要显式的操作导航属性(向其中添加、移除实体)来完成。
一、定制课程的Create和Edit页面
将要完成的效果如下:


课程实体创建后是和某个部门有关联的。为了展示这一点,自动生成的代码生成了相应的控制器方法以及创建、编辑视图,其中包括可选择部门的下拉列表。下拉列表设置 Course.DepartmentID 外键属性,这样 EF 就可以正确加载 Department 导航属性的对应实体。这里只简单修改代码,增加错误处理和下拉列表排序功能。
1.在CourseController.cs中修改Edit和Create动作代码
public ActionResult Create()
{
PopulateDepartmentsDropDownList();
return View();
} [HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(
[Bind(Include = "CourseID,Title,Credits,DepartmentID")]
Course course)
{
try
{
if (ModelState.IsValid)
{
db.Courses.Add(course);
db.SaveChanges();
return RedirectToAction("Index");
}
}
catch (DataException /* dex */)
{
//Log the error (uncomment dex variable name after DataException and add a line here to write a log.)
ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
}
PopulateDepartmentsDropDownList(course.DepartmentID);
return View(course);
} public ActionResult Edit(int id)
{
Course course = db.Courses.Find(id);
PopulateDepartmentsDropDownList(course.DepartmentID);
return View(course);
} [HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(
[Bind(Include = "CourseID,Title,Credits,DepartmentID")]
Course course)
{
try
{
if (ModelState.IsValid)
{
db.Entry(course).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
}
catch (DataException /* dex */)
{
//Log the error (uncomment dex variable name after DataException and add a line here to write a log.)
ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
}
PopulateDepartmentsDropDownList(course.DepartmentID);
return View(course);
} private void PopulateDepartmentsDropDownList(object selectedDepartment = null)
{
var departmentsQuery = from d in db.Departments
orderby d.Name
select d;
ViewBag.DepartmentID = new SelectList(departmentsQuery, "DepartmentID", "Name", selectedDepartment);
}
PopulateDepartmentsDropDownList方法获取按名排列的部门列表,为下拉列表构建一个SelectList集合,使用ViewBag属性将其传递到视图。该方法有一个可选参数 selectedDepartment,以便设置下拉列表默认值。相关视图将把DepartmentID传递给DropDownList帮助器, 帮助器从ViewBag中寻找名为DepartmentID的SelectList。
HttpGet Create调用PopulateDepartmentsDropDownList方法时不使用默认值,因为此时还没有创建新课程数据:
public ActionResult Create()
{
PopulateDepartmentsDropDownList();
return View();
}
HttpGet Edit方法则设置默认值,因为此时课程在编辑时有原始的部门信息:
public ActionResult Edit(int id)
{
Course course = db.Courses.Find(id);
PopulateDepartmentsDropDownList(course.DepartmentID);
return View(course);
}
HttpPost方法在捕获异常之后再次显示创建或编辑页面时,初始化下拉列表默认值:
catch (DataException /* dex */)
{
//Log the error (uncomment dex variable name after DataException and add a line here to write a log.)
ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
}
PopulateDepartmentsDropDownList(course.DepartmentID);
return View(course);
代码确保如果发生异常返回页面时,原有的操作数据还在。
2.修改Create视图
在Views\Course\Create.cshtml, 在Title域之前添加代码,提供录入课程编号的编辑域。之前曾经介绍过,自动生成代码不会保护对主键的编辑域。
model ContosoUniversity.Models.Course
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Course</legend>
<div class="editor-label">
@Html.LabelFor(model => model.CourseID)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.CourseID)
@Html.ValidationMessageFor(model => model.CourseID)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Title)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Title)
@Html.ValidationMessageFor(model => model.Title)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Credits)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Credits)
@Html.ValidationMessageFor(model => model.Credits)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.DepartmentID, "Department")
</div>
<div class="editor-field">
@Html.DropDownList("DepartmentID", String.Empty)
@Html.ValidationMessageFor(model => model.DepartmentID)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
同样地修改Views\Course\Edit、Delete和Details视图,在Title字段前添加course number字段。
<div class="display-label">
@Html.DisplayNameFor(model => model.CourseID)
</div>
<div class="display-field">
@Html.DisplayFor(model => model.CourseID)
</div>
运行Create、Edit、Delete、Details,查看效果。



二、为教师创建Edit页面

当你编辑一条教师记录时,你可能希望能够更新教师的办公地点。Instructor实体和OfficeAssignment之间是一对一的关系,所以必须处理以下情况:
- 如果用户清除了办公地点,而它本来是有值的,那么你必须删除OfficeAssignment实体。
- 如果用户输入办公地点值,而它本来是空的,那么你必须新建一个OfficeAssignment实体。
- 如果用户改变了办公地点的值,那么你必须改变已有的OfficeAssignment实体值。
1.添加办公地点

Instructor控制器中,自动生成的HttpGet Edit方法代码如下:
public ActionResult Edit(int id = )
{
Instructor instructor = db.Instructors.Find(id);
if (instructor == null)
{
return HttpNotFound();
}
ViewBag.InstructorID = new SelectList(db.OfficeAssignments, "InstructorID", "Location", instructor.InstructorID);
return View(instructor);
}
自动生成的代码创建了下拉列表,我们将其修改以下,使用文本框:
public ActionResult Edit(int id)
{
Instructor instructor = db.Instructors
.Include(i => i.OfficeAssignment)
.Where(i => i.InstructorID == id)
.Single();
return View(instructor);
}
使用eager loading贪婪加载方式获取OfficeAssignment实体,就不能使用Find方法,所以我们使用了Where。
将HttpPost Edit方法替换为如下代码。
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, FormCollection formCollection)
{
var instructorToUpdate = db.Instructors
.Include(i => i.OfficeAssignment)
.Where(i => i.InstructorID == id)
.Single(); if (TryUpdateModel(instructorToUpdate, "",
new string[] { "LastName", "FirstMidName", "HireDate", "OfficeAssignment" }))
{
try
{
if (String.IsNullOrWhiteSpace(instructorToUpdate.OfficeAssignment.Location))
{
instructorToUpdate.OfficeAssignment = null;
} db.Entry(instructorToUpdate).State = EntityState.Modified;
db.SaveChanges(); return RedirectToAction("Index");
}
catch (DataException /* dex */)
{
//Log the error (uncomment dex variable name after DataException and add a line here to write a log.
ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
}
}
ViewBag.InstructorID = new SelectList(db.OfficeAssignments, "InstructorID", "Location", id);
return View(instructorToUpdate);
}
这部分代码的作用是:
从数据库通过贪婪加载获取Instructor和OfficeAssignment实体。这是和自动生成的HttpGet Edit方法一样的。
使用模型绑定器数据更新Instructor实体。
if (TryUpdateModel(instructorToUpdate, "",
new string[] { "LastName", "FirstMidName", "HireDate", "OfficeAssignment" }))
- 如果办公室信息为空,将Instructor.OfficeAssignment属性设为null,OfficeAssignment表中相应的记录也将删除。
if (String.IsNullOrWhiteSpace(instructorToUpdate.OfficeAssignment.Location))
{
instructorToUpdate.OfficeAssignment = null;
}
- 保存对数据库的修改。
在Views\Instructor\Edit.cshtml, Hire Date 的div标记之后, 添加办公室信息的编辑域:
<div class="editor-label">
@Html.LabelFor(model => model.OfficeAssignment.Location)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.OfficeAssignment.Location)
@Html.ValidationMessageFor(model => model.OfficeAssignment.Location)
</div>
运行,测试效果。

2.添加教师讲授的课程数据更新
在教师Edit页面,增加对教师承担课程编辑的功能,效果如下。

Course和Instructor实体之间是多对过关系,我们并没有手动生成它们之间的连接表,自动生成的连接表无法直接访问。事实上,我们将通过在Instructor.Courses导航属性中,添加或删除关联实体的方式来实现关系的维护。
改变老师承担课程的功能,是通过一组复选框来实现。列出数据库中所有课程,教师承担某课程,则该复选框选中。用户通过选中或者取消选中的操作修改课程的分配情况。如果课程数目很多,你可能希望使用别的显示方法,但操作导航属性来添加或删除关系的方法是一样的。
为了能够显示这一组复选框,我们将使用视图模型类。在Models文件夹中,创建AssignedCourseData.cs文件。
namespace ContosoUniversity.ViewModels
{
public class AssignedCourseData
{
public int CourseID { get; set; }
public string Title { get; set; }
public bool Assigned { get; set; }
}
}
更新Instructor控制器的Edit方法。
public ActionResult Edit(int id)
{
Instructor instructor = db.Instructors
.Include(i => i.OfficeAssignment)
.Include(i => i.Courses)
.Where(i => i.InstructorID == id)
.Single();
PopulateAssignedCourseData(instructor);
return View(instructor);
} private void PopulateAssignedCourseData(Instructor instructor)
{
var allCourses = db.Courses;
var instructorCourses = new HashSet<int>(instructor.Courses.Select(c => c.CourseID));
var viewModel = new List<AssignedCourseData>();
foreach (var course in allCourses)
{
viewModel.Add(new AssignedCourseData
{
CourseID = course.CourseID,
Title = course.Title,
Assigned = instructorCourses.Contains(course.CourseID)
});
}
ViewBag.Courses = viewModel;
}
代码使用贪婪模式加载Courses导航属性,调用PopulateAssignedCourseData方法实现为视图提供AssignedCourseData视图模型的数据。
PopulateAssignedCourseData方法读取所有Course实体。对每一个Courses检查是否已经存在于某教师的导航属性中。为了提高效率,将当前承担课程的ID形成一个HashSet集合。教师承担某课程,则Assigned属性将设为 true。视图将使用此属性决定哪些选择框处于被选中状态。最后通过ViewBag的一个属性将列表传递到视图。
下一步,完成保存代码。使用如下代码替换HttpPost Edit方法的代码,调用一个新的方法更新Instructor实体的Courses导航属性。
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, FormCollection formCollection, string[] selectedCourses)
{
var instructorToUpdate = db.Instructors
.Include(i => i.OfficeAssignment)
.Include(i => i.Courses)
.Where(i => i.InstructorID == id)
.Single();
if (TryUpdateModel(instructorToUpdate, "",
new string[] { "LastName", "FirstMidName", "HireDate", "OfficeAssignment" }))
{
try
{
if (String.IsNullOrWhiteSpace(instructorToUpdate.OfficeAssignment.Location))
{
instructorToUpdate.OfficeAssignment = null;
} UpdateInstructorCourses(selectedCourses, instructorToUpdate); db.Entry(instructorToUpdate).State = EntityState.Modified;
db.SaveChanges(); return RedirectToAction("Index");
}
catch (DataException /* dex */)
{
//Log the error (uncomment dex variable name after DataException and add a line here to write a log.
ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
}
}
PopulateAssignedCourseData(instructorToUpdate);
return View(instructorToUpdate);
} private void UpdateInstructorCourses(string[] selectedCourses, Instructor instructorToUpdate)
{
if (selectedCourses == null)
{
instructorToUpdate.Courses = new List<Course>();
return;
} var selectedCoursesHS = new HashSet<string>(selectedCourses);
var instructorCourses = new HashSet<int>
(instructorToUpdate.Courses.Select(c => c.CourseID));
foreach (var course in db.Courses)
{
if (selectedCoursesHS.Contains(course.CourseID.ToString()))
{
if (!instructorCourses.Contains(course.CourseID))
{
instructorToUpdate.Courses.Add(course);
}
}
else
{
if (instructorCourses.Contains(course.CourseID))
{
instructorToUpdate.Courses.Remove(course);
}
}
}
因为自动生成的视图中,不包含Course实体集合, 因此模型绑定器不能直接更新Courses导航属性。更新由UpdateInstructorCourses方法完成。因此要把Courses属性从模型绑定器中排除出去。这并不需要修改TryUpdateModel的代码,因为使用了白名单,Courses不在名单之内。
如果没有选中任何课程,UpdateInstructorCourses将Courses导航属性设为一个空的列表:
if (selectedCourses == null)
{
instructorToUpdate.Courses = new List<Course>();
return;
}
代码执行循环检查数据库中的每一课程,若此课程被选中则判断是否已经包含在相关数据中,如果没有则添加到导航属性。为了提高效率,把选中课程 Id和已有课程ID放在哈希表中。
if (selectedCoursesHS.Contains(course.CourseID.ToString()))
{
if (!instructorCourses.Contains(course.CourseID))
{
instructorToUpdate.Courses.Add(course);
}
}
如果某课程没有选中但存在于Instructor.Courses导航属性, 则将其从中移除。
else
{
if (instructorCourses.Contains(course.CourseID))
{
instructorToUpdate.Courses.Remove(course);
}
}
在Views\Instructor\Edit.cshtml文件中,在OfficeAssignment之后,添加课程复选框。
@model ContosoUniversity.Models.Instructor
@{
ViewBag.Title = "Edit";
}
<h2>Edit</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Instructor</legend>
@Html.HiddenFor(model => model.InstructorID)
<div class="editor-label">
@Html.LabelFor(model => model.LastName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.LastName)
@Html.ValidationMessageFor(model => model.LastName)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.FirstMidName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.FirstMidName)
@Html.ValidationMessageFor(model => model.FirstMidName)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.HireDate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.HireDate)
@Html.ValidationMessageFor(model => model.HireDate)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.OfficeAssignment.Location)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.OfficeAssignment.Location)
@Html.ValidationMessageFor(model => model.OfficeAssignment.Location)
</div>
<div class="editor-field">
<table>
<tr>
@{
int cnt = ;
List<ContosoUniversity.ViewModels.AssignedCourseData> courses = ViewBag.Courses;
foreach (var course in courses) {
if (cnt++ % == ) {
@: </tr> <tr>
}
@: <td>
<input type="checkbox"
name="selectedCourses"
value="@course.CourseID"
@(Html.Raw(course.Assigned ? "checked=\"checked\"" : "")) />
@course.CourseID @: @course.Title
@:</td>
}
@: </tr>
}
</table>
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
这段代码创建了一个包含三列的表格。每一列包含一个复选框、课程编号和名称。所有复选框的名字都是一样的 ("selectedCourses"), 模型绑定器由此得知将其作为一组信息来处理。复选框的 value设为对于课程的 CourseID。当编辑提交之后,模型绑定器将被选中的复选框的值组合为一个数组传给控制器。
更新Views\Instructor\Index.cshtml视图,在Office列之后添加Courses,更新Details视图。
@model ContosoUniversity.ViewModels.InstructorIndexData
@{
ViewBag.Title = "Instructors";
}
<h2>Instructors</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th></th>
<th>Last Name</th>
<th>First Name</th>
<th>Hire Date</th>
<th>Office</th>
<th>Courses</th>
</tr>
@foreach (var item in Model.Instructors)
{
string selectedRow = "";
if (item.InstructorID == ViewBag.InstructorID)
{
selectedRow = "selectedrow";
}
<tr class="@selectedRow" valign="top">
<td>
@Html.ActionLink("Select", "Index", new { id = item.InstructorID }) |
@Html.ActionLink("Edit", "Edit", new { id = item.InstructorID }) |
@Html.ActionLink("Details", "Details", new { id = item.InstructorID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.InstructorID })
</td>
<td>
@item.LastName
</td>
<td>
@item.FirstMidName
</td>
<td>
@String.Format("{0:d}", item.HireDate)
</td>
<td>
@if (item.OfficeAssignment != null)
{
@item.OfficeAssignment.Location
}
</td>
<td>
@{
foreach (var course in item.Courses)
{
@course.CourseID @: @course.Title <br />
}
}
</td>
</tr>
}
</table>
@if (Model.Courses != null)
{
<h3>Courses Taught by Selected Instructor</h3>
<table>
<tr>
<th></th>
<th>ID</th>
<th>Title</th>
<th>Department</th>
</tr>
@foreach (var item in Model.Courses)
{
string selectedRow = "";
if (item.CourseID == ViewBag.CourseID)
{
selectedRow = "selectedrow";
}
<tr class="@selectedRow">
<td>
@Html.ActionLink("Select", "Index", new { courseID = item.CourseID })
</td>
<td>
@item.CourseID
</td>
<td>
@item.Title
</td>
<td>
@item.Department.Name
</td>
</tr>
}
</table>
}
@if (Model.Enrollments != null)
{
<h3>Students Enrolled in Selected Course</h3>
<table>
<tr>
<th>Name</th>
<th>Grade</th>
</tr>
@foreach (var item in Model.Enrollments)
{
<tr>
<td>
@item.Student.FullName
</td>
<td>
@Html.DisplayFor(modelItem => item.Grade)
</td>
</tr>
}
</table>
}
运行Instructor Index,查看效果。点击Edit查看功能,修改一些课程的分配,然后点击Save,修改结果在Index页面展示。

这种方式在课程数目不多时有效。如果课程数目很多需要修改显示方式和更新方法。
3.更新Instructor的Delete方法
修改代码,当删除教师时,为其分配的办公室信息随之删除:
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Instructor instructor = db.Instructors
.Include(i => i.OfficeAssignment)
.Where(i => i.InstructorID == id)
.Single();
foreach (var department in db.Departments)
{
if (department.InstructorID == id)
{
department.InstructorID = null;
}
}
db.Instructors.Remove(instructor);
db.SaveChanges();
return RedirectToAction("Index");
}
已经完成了完整的CRUD操作,但没有处理同步问题。下一节将引入同步问题,介绍处理方法,为CRUD操作添加同步处理。
演练5-5:Contoso大学校园管理系统5的更多相关文章
- 演练5-3:Contoso大学校园管理系统3
在前面的教程中,我们使用了一个简单的数据模型,包括三个数据实体.在这个教程汇中,我们将添加更多的实体和关系,按照特定的格式和验证规则等自定义数据模型. Contoso大学校园管理系统的数据模型如下. ...
- 演练5-6:Contoso大学校园管理系统6
在上一次的教程中,我们处理了关联数据问题.这个教程演示如何处理并发问题.你将使用Department实体创建一个页面,这个页面在支持编辑和删除的同时,还可以处理并发错误.下面的截图演示了Index页面 ...
- 演练5-4:Contoso大学校园管理系统4
在之前的教程中,我们已经完成了学校的数据模型.现在我们将读取和显示相关数据,请理解EF加载导航属性的方式. 一.Lazy.Eager.Explicit数据加载 使用EF为实体中的导航属性加载相关数据, ...
- 演练5-7:Contoso大学校园管理系统(实现继承)
***操作视频下载:1 *** 在上一次教程中,你已经能够处理并发异常.这个教程将会展示如何在数据模型中实现继承. 在面向对象的程序设计中,你可以通过继承来清除冗余的代码.在这个教程中,你将要 ...
- 演练5-8:Contoso大学校园管理系统(实现存储池和工作单元模式)
在上一次的教程中,你已经使用继承来消除在 Student 和 Instructor 实体之间的重复代码.在这个教程中,你将要看到使用存储池和工作单元模式进行增.删.改.查的一些方法.像前面的教程一样, ...
- 演练5-1:Contoso大学校园管理1
**演练目的:掌握复杂模型的应用程序开发. Contoso大学校园管理系统功能包括学生.课程.教师的管理. 一.创建MVC Web应用程序 显示效果如下图,操作步骤略. 二.创建数据模型 1.创建学生 ...
- 演练5-2:Contoso大学校园管理2
一.添加列标题排序功能 我们将增加Student/Index页面的功能,为列标题添加超链接,用户可以点击列标题对那一列进行排序. 1.修改Index方法 public ActionResult Ind ...
- Contoso 大学 - 使用 EF Code First 创建 MVC 应用,实例演练
Contoso 大学 Web 示例应用演示了如何使用 EF 技术创建 ASP.NET MVC 应用.示例中的 Contoso 大学是虚构的.应用包括了类似学生注册.课程创建以及教师分配等功能. 这个系 ...
- Contoso 大学 - 7 – 处理并发
原文 Contoso 大学 - 7 – 处理并发 By Tom Dykstra, Tom Dykstra is a Senior Programming Writer on Microsoft's W ...
随机推荐
- Knockout快速扫盲
1.Knockout.js是什么? Knockout是一款很优秀的js库,它可以快速让你使用一个干净整洁的底层数据模型,即可创建一个富文本且具有良好显示和编辑功能的用户界面.任何时候你的ui需要自 ...
- 【QT相关】文件、目录基础操作
判断目录是否存在: QString proFile(t_path); proFile.append("/dir"); QFileInfo proFileInfo(proFile); ...
- JS 某一区域内所有CheckBox全选和取消全选(.net)
假设在某个table中的两个td,一个放全选checkbox,一个放所有的checkbox[其他标签类似] eg: <td>人才类别:<asp:CheckBox ID= ...
- android linearlayout 把控件view置底部(放在页面最下方)
<LinearLayout android:id="@+id/recLayout" android:layout_width="fill_parent" ...
- 【第三方SDK】百度地图实现最简单的定位功能(无地图界面)
在近期的项目中,须要实现无地图界面的定位功能,定位用户所在的城市.因此,本篇文章,主要介绍怎样使用百度地图SDK实现无导航界面的定位功能. 1.申请百度开发人员账户 2.创建应用,获取key 例如以下 ...
- 字符设备驱动: register_chrdev和register_chrdev_region
概述: register_chrdev与unregister_chrdev配对使用: /*register_chrdev = __register_chrdev_region (一次性256个子设备, ...
- JAVA 中URL链接中文参数乱码的若干处理方法
方法一: http://xxx.do?ptname='我是中国人' String strPtname = request.getParameter("ptname"); strPt ...
- Android,机器狗应用
源码如下: package com.wyl.jqr; import java.io.BufferedReader; import java.io.IOException; import java.io ...
- pl/sql 中F8执行单行sql
pl/sql中设置: tools->preferences->sql window->AutoSelect statement
- tomcat编译通过问题
tomcat 编译后 的类 和 网站目录不能同名!