processnewresponseaction.java

来自「JAVA Servlet2.3外文书籍源码」· Java 代码 · 共 36 行

JAVA
36
字号
package forum;

import javax.servlet.http.*;

/**
 * Represents the logic behind processing a new response. This action
 * is responsible for looking up the appropriate Topic instance, creating
 * a new Response instance and adding it to the topic.
 *
 * @author    Simon Brown
 */
public class ProcessNewResponseAction extends Action {

  /**
   * Peforms the processing associated with this action.
   *
   * @param request     the HttpServletRequest instance
   * @param response    the HttpServletResponse instance
   * @return  the name of the next view
   */
  public String process(HttpServletRequest request, HttpServletResponse response) {

    System.out.println("ProcessNewResponseAction : Processing request");

    String text = request.getParameter("text");
    int id = Integer.parseInt(request.getParameter("id"));

    User user = (User)request.getSession().getAttribute("user");

    Topic topic = Topics.getTopic(id);
    topic.add(new Response(user, text));

    return "/controller/ViewTopic?id=" + id;
  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?