servlet模块 配置访问路径参数
// uri:/store/company?operation=list
uri 访问路径
?号后面是他的参数
operation 参数名称
=list 这个list 是参数的值
String operation = req.getParameter("operation");
if ("list".equals(operation)){
this.list(req,resp);
}else if ("toAdd".equals(operation)){
this.toAdd(req,resp);
}else if("save".equals(operation)){
this.save(req,resp);
}else if ("toEdit".equals(operation)){
this.toEdit(req,resp);
}else if("edit".equals(operation)){
this.edit(req,resp);
}else if("delete".equals(operation)){
this.delete(req,resp);
}
用 req.getParameter(“operation”);
得到访问路径 中 参数名称中的值
然后对 访问路径中的参数名称进行判断
判断参数名称的值
是 什么 就调用什么方法
这个什么方法的名称 与参数的值要一致
在这个什么方法中编写 接受对应的请求数据
或将从业务层传递上来的数据发送到共享域中
页面才能从共享域中获取到相应的数据
但要先试一下在这里跳页面能否成功
if ("list".equals(operation)){
req.getRequestDispatcher("/WEB-INF/pages/store/company/update.jsp").forward(req,resp);
}
就像这样
跳转的页面要放在 WEB-INF 内
但 home模块中的页面就不要放进去
也就是主页面
在外面的 web文件夹内page模块中
只留home 主页面模块
然后在主页面的菜单栏的访问路径
写
/store/company?operation=list
<li id="company-manager">
<a href="${ctx}/store/company?operation=list" onclick="setSidebarActive(this)" target="iframe">
<i class="fa fa-circle-o"></i>企业管理
</a>
</li>
就是让 页面的 企业管理 菜单栏 使用
/store/company这个路径 找到 list 方法进行查询数据操作
这也页面信息才能显示在页面浏览器中