邓叔叔 2017-12-26 01:13 采纳率: 0%
浏览 5504
已结题

JAVA SSM访问web-inf目录下jsp问题

这是web.xml配置

<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">

<display-name>Archetype Created Web Application</display-name>

<filter>
    <filter-name>characterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>characterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:applicationContext.xml
    </param-value>
</context-param>

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>



<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

<!-- MVC Servlet -->
<servlet>
    <servlet-name>springServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:/spring-mvc*.xml</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>springServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
</welcome-file-list>

这是spring-mvc.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:mvc="http://www.springframework.org/schema/mvc" xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:tx="http://www.springframework.org/schema/tx"

   xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd

    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-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/cache http://www.springframework.org/schema/cache/spring-cache-4.2.xsd">

<description>Spring MVC Configuration</description>

<!--加载属性配置文件-->
<context:property-placeholder ignore-unresolvable="true" location="classpath:mes.properties"/>


<!--</bean>-->


<!--配置Annotation驱动, 扫描@Transaction注解的类定义事务-->
<tx:annotation-driven proxy-target-class="true"/>



<!-- 对静态资源文件的访问,将无法mapping到Controller的path交给default servlet handler处理 -->
<mvc:default-servlet-handler/>

<!-- 定义无Controller的path<->view直接映射 -->
<!--<mvc:view-controller path="/" view-name="redirect:/loginPage.do/"/>-->

<!--静态资源文件映射-->
<mvc:resources mapping="/static/**" location="/static/" cache-period="31530000"/>






<!--定义视图文件解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="${web.view.prefix}"/>
    <property name="suffix" value="${web.view.suffix}"/>
</bean>

<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    <property name="exceptionMappings">
        <props>
            <prop key="org.apache.shiro.authz.UnauthorizedException">error/403</prop>
            <prop key="java.lang.Throwable">error/500</prop>
        </props>
    </property>
</bean>

<!--上传文件拦截器, 设置最大上传文件大小   10M=10*1024*1024 (bytes)-->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize" value="${web.maxUploadSize}"/>
    <property name="defaultEncoding" value="UTF-8"/>
</bean>

<!--<bean id="lifecycleBeanPostProcessor"-->
      <!--class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>-->
<!--<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"-->
      <!--depends-on="lifecycleBeanPostProcessor"/>-->
<!--<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">-->
    <!--<property name="securityManager" ref="securityManager"/>-->
<!--</bean>-->

这是请求代码

@RequestMapping(value = "main.do", method = RequestMethod.GET)
public String index1(HttpServletRequest request, HttpServletResponse response) throws IOException {
User user = (User) request.getSession().getAttribute("admin");
if (user == null) {
//session中没有用户信息就重登
return "redirect:/loginPage.do";
}
System.out.println("登录名:" + user.getNickname());
ModelAndView index = new ModelAndView("index");
return "index";
}

浏览器请求

图片说明
总是无法调转页面,404.请问是哪里出错了

  • 写回答

20条回答 默认 最新

  • qq_36011374 2017-12-26 01:23
    关注

    你这个没有扫描类包啊

    评论

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示