发表于: 2017-08-01 23:33:15

3 1098


今日完成的事:

解决了404,和页面无法跳转的问题.

昨天找两位师兄细细研究得知,我的idea编码设置还有运行的jdk编译版本有问题,在调整过后,在把springmvc下的配置文件 设置扫描controller的元素就解决了.由于昨天太困了.先睡了,没有把问题详细总结 和配置文件的记录下来.明天再做统一的总结

在此记录一下

<?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:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:task="http://www.springframework.org/schema/task"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
        http://www.springframework.org/schema/task
        http://www.springframework.org/schema/task/spring-task-3.1.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
             
我在spring-mybatis config配置文件下加入controller扫描,没有在springmvc的xml文件配置,导致无法扫描到controller 
<context:component-scan base-package="com.jnshu.controller"/>
             <!--配置springmvc,开启注解功能-->
           <mvc:annotation-driven/>

<!--静态资源默认servlet配置-->
   <mvc:default-servlet-handler/>

<!--配置试图解析器,jsp显示view-->
 <!--  org.springframework.web.servlet.view.InternalResourceViewResolver-->
      <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>-->
           <property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
<!-- <property name="order" value="0"/>-->
      </bean>

</beans>

继续在jsp页面以 c:forEach items="${studentList}" 输出数据集合

<%--
 Created by IntelliJ IDEA.
 User: PC
 Date: 2017/7/31
 Time: 16:31
 To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<h4>aaa</h4>
<c:forEach items="${studentList}" var="student">
<c:out value="${student}"/>


</c:forEach>


</body>
</html>

利用idea内置的test restful 测试一下,可以查到结果,表示方法成功了

明日的计划:把剩下的crud解决,和总结




遇到的问题:两个星期的404问题





收获:在jsp要用c:forEach标签输出数据,idea的编码设置,在pom文件中,设置jdk默认编译版本


返回列表 返回列表
评论

    分享到