发表于: 2018-09-10 22:31:38

1 491



今日完成:

补全脑图


今天刚开始任务二,先建了个web项目。

下载tomcat并配置环境变量。

springmvc.xml文件需要的内容:


<!--  配置扫描的包 -->
   <context:component-scan base-package="TestJson"/>

   <!--  访问静态资源-->
   <mvc:default-servlet-handler />

   <!--  注册映射类 -->
   <mvc:annotation-driven />

   <!--  视图解析器 -->
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
         id="internalResourceViewResolver">
       <!-- 前缀 -->
       <property name="prefix" value="/WEB-INF/jsp/" />
       <!-- 后缀 -->
       <property name="suffix" value=".jsp" />
   </bean>
</beans>

web.xml文件:

  <!--配置监听器-->
   <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>
<servlet>
   <servlet-name>springmvc</servlet-name>
   <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <init-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>classpath:springmvc.xml</param-value>
   </init-param>
</servlet>

   <!--拦截规则-->
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

添加依赖jar包

<dependencies>
 <dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
   <version>5.1.34</version>
 </dependency>
 <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.11</version>
   <scope>test</scope>
 </dependency>
 <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>javax.servlet-api</artifactId>
   <version>4.0.0</version>
   <scope>provided</scope>
 </dependency>

 <dependency>
   <groupId>javax.servlet.jsp</groupId>
   <artifactId>jsp-api</artifactId>
   <version>2.2</version>
 </dependency>
 <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>

 </dependency>
 <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context</artifactId>
   <version>4.3.5.RELEASE</version>
 </dependency>
   <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-tx</artifactId>
     <version>4.3.5.RELEASE</version>
   </dependency>
 <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>4.3.5.RELEASE</version>
 </dependency>
 <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>4.3.5.RELEASE</version>
 </dependency>
 <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-beans</artifactId>
   <version>4.3.5.RELEASE</version>
 </dependency>
</dependencies>

安照教程已经跑通了Hello World,但后面tomcat出了问题,解决不掉。

查看tomcat日志

9月 10, 2018 10:24:59 下午 org.apache.catalina.core.StandardContext startInternal

严重: One or more listeners failed to start. Full details will be found in the appropriate container log file

9月 10, 2018 10:24:59 下午 org.apache.catalina.core.StandardContext startInternal

严重: Context [] startup failed due to previous errors

9月 10, 2018 10:24:59 下午 org.springframework.web.context.support.XmlWebApplicationContext doClose

信息: Closing Root WebApplicationContext: startup date [Mon Sep 10 22:24:59 CST 2018]; root of context hierarchy

9月 10, 2018 10:24:59 下午 org.springframework.web.context.support.XmlWebApplicationContext doClose

警告: Exception thrown from LifecycleProcessor on context close

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Mon Sep 10 22:24:59 CST 2018]; root of context hierarchy

也没找到解决的办法。

整了个静态页面html:

<html>

  <head>

   <title>Input Information</title>

  </head>

  <body>

   <h3>Input Your Information<h3>

   <form name="form1" method="GET" action="JSPhandle.jsp">

     NAME:<input type=text name="NAME"><br>

     SEX:&nbsp;<select name="SEX">

           <option value="1" selected>MALE</option>

           <option value="2">FEMALE</option>

         </select><br>&nbsp;&nbsp;&nbsp;&nbsp;

     <input type="submit" name="SUBMIT" value="submit">&nbsp;&nbsp;

     <input type="reset" name="RESET" value="reset">

    </form>

   </body>

</html>


明日计划:


实在不行就得重装tomcat了

遇到的问题:

感觉对还是对web项目的一些基本流程没有搞清,出了错也不知道该怎么解决了,照着教程搞了一天都不知道自己在干什么。还是得慢慢来,步子大了容易扯到蛋。

收获:

。。。


返回列表 返回列表
评论

    分享到