gpt4 book ai didi

java - JSF Servlet 导致奇怪的行为

转载 作者:行者123 更新时间:2023-11-30 04:12:23 25 4
gpt4 key购买 nike

我有一个 servlet,其全部目的是根据传递到其中的参数将用户重定向到页面。但是,当我重定向到某个页面时,单击的任何按钮都会导致该页面重定向到我的登陆页面。

Controller :

@WebServlet(name = "Case1Controller", urlPatterns = {"/C1Control"})
public class Case1Controller extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String jsf = request.getParameter("jsf");
if(jsf.equalsIgnoreCase("V")) {
response.sendRedirect(response.encodeRedirectURL("AddVendor.jsf"));
}
if(jsf.equalsIgnoreCase("P")) {
response.sendRedirect(response.encodeRedirectURL("AddProduct.jsf"));
}
if(jsf.equalsIgnoreCase("O")) {
response.sendRedirect(response.encodeRedirectURL("POGenerator.jsf"));
}
}
}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}


@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}


@Override
public String getServletInfo() {
return "Short description";
}

}

用法:

 < ul>
< m:MenuItem caption="Add Vendor" jsf="V"/>
< m:MenuItem caption="Add Product" jsf="P"/>
< m:MenuItem caption="Generate PO" jsf="O"/>
< /ul>

菜单项控制:

<!-- INTERFACE -->
<cc:interface>
<cc:attribute name="caption" required="true"/>
<cc:attribute name="jsf" required="true"/>
</cc:interface>

<!-- IMPLEMENTATION -->
<cc:implementation>
<h:outputLink value="/Info5059Case1/C1Control?jsf=#{cc.attrs.jsf}"> #{cc.attrs.caption}</h:outputLink>&nbsp;

</cc:implementation>

最佳答案

您的按钮中是否有某些内容导致抛出您未捕获的异常?这可能会导致 Controller 重定向您。

关于java - JSF Servlet 导致奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19297577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com