我的代码是否遵循MVC模式? [英] Is my code follows MVC Pattern?
本文介绍了我的代码是否遵循MVC模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的jsp页面..我从模态类获取方法并迭代表..
This is my jsp page.. I am getting the method from modal class and iterating the table..
<html>
<body>
<%ArrayList<Employee> empList=new ArrayList<Employee>();
ModalClass emp=new ModalClass();
empList = emp.getEmployess();
<!-- With this list i will iterate my table -->
</body>
</html>
这是我的模态类(java),是用于从db获取值。
And this is my modal class(java), is used to fetch the values from db.
public Class ModalClass {
public ArrayList<Employee> getEmployess(){
//In this method i am fetching the db values and storing into the List and returning the list...
return list;
}
我希望读者能够理解我的编码,现在我的问题是我的代码遵循MVC模式..
提前谢谢...
I hope the reader can understand my coding,now my question is Wheather my code follows MVC pattern..
Thanks in advance...
推荐答案
查看此文章
模型视图带有JSP和JSTL的Controller(MVC) [ ^ ]
我不太确定你的代码是否遵循MVC模式
在MVC中
1.Model:模型是数据类的位置,看起来你使用ModalClass类来完成这个工作
2查看:这应该是几乎纯HTML,不应该有任何数据访问类启动/方法,你使用以下来打败这个
I am not too sure whether your code follows MVC pattern
In MVC
1.Model : Model is where the data classes, looks you have done this using the class "ModalClass"
2 View : This should be almost pure HTML and should not have any data access class initiations / methods and you are defeating this by using the following
<%ArrayList<Employee> empList=new ArrayList<Employee>();
ModalClass emp=new ModalClass();
empList = emp.getEmployess();
<!-- With this list i will iterate my table
3.控制器:这是你将拥有任何数据访问类启动/方法的地方,在你的情况下它将丢失。
我认为您的代码不满足MVC模式
3. Controller : This is where you will have any data access class initiations / methods and its missing in your case.
I think you code does not satisfy the MVC pattern
参考此链接
www.oracle.com/technetwork/articles/javase/index-142890.html [ ^ ]
这篇关于我的代码是否遵循MVC模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文