如何使用:href引用WEB INF中的页面

时间:2015-03-25 07:54:59

标签: jsp spring-mvc

我的所有jsp页面都在webapp / WEB-INF / jsp中。所以我无法从a:href访问这些页面。请告诉我一些使这些a:href正常工作的方法

引入了menu.jsp

<a:href=”mainmenu/Menu1.jsp”>

Menu1.jsp页面位于webapp / WEB-INF / jsp / mainmenu / Menu1.jsp

我的spring-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">

    <context:annotation-config />
    <!-- Scans within the base package of the application for @Components to configure-->
    <context:component-scan base-package="com.bankofny.inx.omx.lc.web" />

    <!-- Enables the Spring MVC @Controller programming model -->
    <mvc:annotation-driven />

    <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="resources.application" />
    </bean>


    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView"></property>
        <property name="prefix" value="/WEB-INF/jsp/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean> 

控制器:

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class ClsSaveAction implements OMXServiceIDs {
@RequestMapping(value = "/ClsSave", method = RequestMethod.POST)
    public ModelAndView execute(HttpServletRequest  request,
                                 HttpServletResponse response,
                                 @ModelAttribute("clsData") ClauseData clauseData,
                                 BindingResult bindingResult,
                                 Model model)
        throws Exception {

        System.out.println("inside this method");
        model.addAttribute("clsData", new ClauseData());

        try
        {
          .
.
.
.
.
.

            return new ModelAndView("blank", "clsData", new ClauseData());


        }

        catch (Exception e) {

          throw e;
        }
    }
}

1 个答案:

答案 0 :(得分:0)

你做不到。外部程序无法加载WEB-INF内的页面,例如浏览器。

把它放在其他地方。