我正在做网络应用程序。我在编辑数据时遇到问题
我想创造这样的东西
我希望你能帮助我找到方法来做到这一点。我找到了下一个变体,但我不知道人们通常会这样做。
- 以一种形式多次提交。
- 在一个表格中提交超过 1 个。
- 或 1 个 JSP 中的一种以上形式
而且我不应该使用任何框架。并且没有javascript。
谢谢
好的,如果它有助于理解我想在 servlet 上得到什么,我会展示 selvlet 的某些部分
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String page = new String();
Command command = CommandFactory.getCommand(request);
page = command.execute(request);
if (page != null) {
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(page);
dispatcher.forward(request, response);
}
....
}
和 CommandFactory
public static Command getCommand(HttpServletRequest request){
Command current = new NoCommand();
String action = request.getParameter("command");
if(action == null || action.isEmpty()){
return current;
}
try{
CommandEnum currentState = CommandEnum.valueOf(action.toUpperCase());
current = currentState.getCurrentCommand();
}
...
}
和 CommandEnum
public enum CommandEnum {
EDIT_QUESTION {
{
this.command = new EditQuestionCommand();
}
};
}
特别是命令我做一些业务逻辑
请帮助我找到从 jsp 值作为 command="delete" 获取的方法。通过单次提交,我使用隐藏字段。我们如何为几个按钮做同样的事情?