HttpServlet이 있습니다. 사용자를 다른 JSP 페이지로 리디렉션합니다. 사용자가 원하는 작업에 따라 다릅니다. 예 : http://localhost:8080/collections/index.do
은 index.jsp로 리디렉션됩니다. 나는 액션 이름을 가져올 수) 1 - - 사용자가 브라우저에서 이전 URL을 쓸 때 다른 조치는 나는이사용자 지정 jsp 페이지로 리디렉션
<component-instance key="index">
<com.epam.collections.web.IndexAction/>
</component-instance>
처럼 picocontainer 유지 index
String name = getActionName(req);
2) picocontainer의 조치를 받기
Action action = (Action) pico.getComponentInstance(name);
3) 작업 수행 - JSP 페이지 이름을 나타내는 문자열 반환
String view = action.exec(req, resp);
간부 인 방법은 내가 picocontainer의 행동이 없을 때 페이지 notfound.jsp
에 사용자를 전달할
public String exec(HttpServletRequest req, HttpServletResponse resp) {
return "index";
}
4) 앞으로 사용자
getServletContext().getRequestDispatcher(
"/WEB-INFO/pages/" + view + ".jsp").forward(req, resp);
index.jsp page
에입니다. 예를 들어 blabla.do
은 notfound.jsp
페이지를 반환해야합니다. 나는이
if (action == null) {
getServletContext().getRequestDispatcher(
"/WEB-INF/jsp/notfound.jsp").forward(req, resp);
return;
}
getComponentInstance
때문에 반환 null
을 같이 할 때 작업은 XML 파일에 존재하지 않는 경우 - 내가있어 오류가 나는 .do
없이 STH를 쓸 때 500
이 또한 내가 해당 페이지로 리디렉션 할 조금도. 예를 들어 ddd.dd
, plain
등.하지만 404 오류가 발생했습니다.