JSP link 到控制器映射,returns 映射到 jsp 文件,但浏览器没有显示任何内容

JSP link to controller mapping that returns mapping to jsp file but browser has nothing to show

我有一个link

<a href="<c:url value="localhost:8080/CustomerRelationshipManagement/configureUpdate?
                            firstName=${temp.firstName}&lastName=${temp.lastName}&email=${temp.email}"/>">Update</a>

指向 spring mvc 映射

@RequestMapping(value="configureUpdate", method = RequestMethod.GET)
public String configureUpdate(@RequestParam("firstName") String firstName, 
        @RequestParam("lastName") String lastName,  @RequestParam("email") String email, 
        Model model)
{

    Customer customer = new Customer(firstName, lastName, email);

    model.addAttribute("customer", customer);

    return "update-customer";
}

因此,eclipse 中的浏览器只显示

The webpage cannot be displayed

我已尝试补救此问题,但尚未发现任何方法可以让浏览器在处理完成后继续到下一个 JSP 页面。

The webpage cannot be displayed

这是一个典型的 Internet Explorer 错误消息,当浏览器首先无法到达目标时将显示该错误消息。例如,由于损坏的 URL 语法。

如果您检查了 JSP 页面生成的 HTML 输出,您会注意到它生成了以下 HTML 代码:

<a href="localhost:8080/CustomerRelationshipManagement/configureUpdate?
                        firstName=&lastName=&email=">Update</a>

它不以方案或 / 开头,因此它与当前的 URL 相关。想象一下,当前的URL是http://localhost:8080/CustomerRelationshipManagement/some.jsp,那么目标URL就会变成http://localhost:8080/CustomerRelationshipManagement/localhost:8080/CustomerRelationshipManagement/configureUpdate?firstName=&lastName=&email=

这肯定是无效的。目标 URL 应该变成 http://localhost:8080/CustomerRelationshipManagement/configureUpdate?firstName=&lastName=&email=.

换句话说,生成的 HTML 输出应该如下所示:

<a href="http://localhost:8080/CustomerRelationshipManagement/configureUpdate?
                        firstName=&lastName=&email=">Update</a>

或相对域:

<a href="/CustomerRelationshipManagement/configureUpdate?
                        firstName=&lastName=&email=">Update</a>

或者如果当前页面当前位于 /CustomerRelationshipManagement 文件夹中:

<a href="configureUpdate?firstName=&lastName=&email=">Update</a>

您需要相应地调整您的 JSP 代码,以使其准确生成所需的 HTML 代码。如果 JSP 页面由与目标 URL 完全相同的 Web 应用程序提供服务,并且您想继续使用 <c:url> 标签,那么它应该如下所示:

<c:url var="configureUpdateURL" value="/configureUpdate">
    <c:param name="firstName" value="${temp.firstName}" />
    <c:param name="lastName" value="${temp.lastName}" />
    <c:param name="email" value="${temp.email}" />
</c:url>

<a href="${configureUpdateURL}">Update</a>

它将生成一个域相关 URL。