2012-07-08 146 views
0

上的链接时,我有我的弹簧应用程序的servlet.xml中宣布的2种豆:错误404点击一个jsp页面

<bean name="/apple.htm" class="controller.AppleController"/> 

<bean name="/secure/banana.htm" class="controller.BananaController"/> 

这里是香蕉控制器:

public class BananaController implements Controller { 

    protected final Log logger = LogFactory.getLog(getClass()); 

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) 
      throws ServletException, IOException { 
     logger.info("returning contact view"); 
     return new ModelAndView("/banana"); 
    } 

} 

这里是AppleController

public class AppleController implements Controller { 

    protected final Log logger = LogFactory.getLog(getClass()); 

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) 
      throws ServletException, IOException { 
     logger.info("returning contact view"); 
     return new ModelAndView("/apple"); 
    } 

} 

这里是Apple.jsp(Banana.jsp是相似的):

<%@ include file="/WEB-INF/pages/include.jsp" %> 
<html> 
<body> 
    <h1>Test</h1> 
    <%@ include file="/WEB-INF/pages/menu.jsp" %> 
    <h2>Apple</h2> 
    <p> 
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac mauris ante. 
    </p> 

</body> 
</html> 

这里是引入了menu.jsp:

<a href="<c:url value="apple.htm" />" > Apple</a> 
<a href="<c:url value="secure/banana.htm" />" > Banana</a> 
<a href="<c:url value="/j_spring_security_logout" />" > Logout</a> 

的问题是,一旦我登录,我可以访问banana.htm,不过呢,如果我回去的“苹果”页面,它会尝试访问secure/apple.htm页面,因为我已经位于/ secure文件夹中。

我知道../apple.htm会正确重定向,但没有任何信息告诉我该链接只能从banana.htm中点击。我相信我在这里失去了一些东西。

回答

0

<a href="<c:url value="/apple.htm" />" > Apple</a>