JAVA

Eclipse→File→New→Project..

WEB

右键mvn项目→Properties

src/main/webapp

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>mvn</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.25.RELEASE</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.4</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>
</project>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param> <listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <filter>
<filter-name>httpPutFormContentFilter</filter-name>
<filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class>
</filter> <filter>
<filter-name>characterEncoding</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>
</filter> <filter-mapping>
<filter-name>httpPutFormContentFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <filter-mapping>
<filter-name>characterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <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-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>SpringMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> <session-config>
<session-timeout>10</session-timeout>
</session-config> <!-- <welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list> --> </web-app>

applicationContext.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <!-- 扫描指定目录下的注解,将@Service,@Repository,@Controller,@Component等这些注解的类注册为bean
如果配置了<context:component-scan>那么<context:annotation-config/>标签就可以不用在xml中再配置了,前者包含后者
注:在注解后加上例如@Component(value=”abc”)时,注册的这个类的bean的id就是adc -->
<context:component-scan base-package="com.test" /> <!--
<bean id="iservice" class="com.project.OTHER.db.Access" factory-method="getService"></bean>
--> </beans>

springmvc-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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 自动注册RequestMappingHandlerMapping与RequestMappingHandlerAdapter两个Bean,这是Spring MVC为@Controller分发请求所必需的 -->
<mvc:annotation-driven/>
<!-- 配置了 context:component-scan就不用配置这个了
<context:annotation-config/> -->
<!-- 使用默认的Servlet来响应静态文件 -->
<mvc:default-servlet-handler/>
<!-- 设置使用注解的类所在的jar包 -->
<context:component-scan base-package="com.test.controller" />
<!-- 启动对@AspectJ注解的支持 log begin-->
<!-- proxy-target-class等于true是强制使用cglib代理,proxy-target-class默认是false,如果你的类实现了接口 就走JDK代理,如果没有,走cglib代理 -->
<!-- 注:对于单例模式建议使用cglib代理,虽然JDK动态代理比cglib代理速度快,但性能不如cglib -->
<!--如果不写proxy-target-class="true"这句话也没问题-->
<aop:aspectj-autoproxy proxy-target-class="true"/>
<!--切面-->
<!--添加页面视图解析器-->
<!-- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/html/"/>
<property name="suffix" value=".html"/>
<property name="contentType" value="text/html;charset=UTF-8"/>
</bean> -->
</beans>

TestController.java

package com.test.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; @Controller
@RequestMapping(value = "/test")
public class TestController { // @Resource
// private IService iservice; @RequestMapping(value = "/test", method = RequestMethod.GET)
public String logingui(HttpServletRequest request, HttpServletResponse response) {
try {
response.setCharacterEncoding("UTF-8");
response.getWriter().print("success");
} catch (Exception e) {
e.printStackTrace();
}
return null;
} }

eclipse创建java和web工程的更多相关文章

  1. 使用Eclipse创建动态的web工程

    使用Eclipse创建动态的web工程 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.修改工作区的编码 1>.点击Window选择Preferences 2>.将默 ...

  2. MAVEN创建JAVA的Web工程

    maven命令:http://blog.csdn.net/edward0830ly/article/details/8748986 1.创建MAVEN的Web工程 mvn archetype:gene ...

  3. 【Java_SSM】(二)使用eclipse创建一个Maven web工程

    这篇博文我们介绍一下如何利用eclipse创件一个maven web工程. (1)File--New--Other--Maven--Maven project 此处我们快速创建一个maven工程 点击 ...

  4. 使用eclipse创建spring mvc web工程并部署

    创建maven工程

  5. IDEA 创建JAVA Maven Web 工程

    转载自https://www.cnblogs.com/1314wamm/p/7475771.html 步骤一:首先先创建一个project,上次我说过了创建一个project就是一个工作空间,在这里就 ...

  6. IDEA 创建JAVA Maven Web 工程 不能建Sevlet文件

    JAVA目录下建包而不是文件夹 需要添加依赖 <dependency> <groupId>javax.servlet</groupId> <artifactI ...

  7. Eclipse创建java web工程

    Eclipse创建java web工程 eclipse版本:eclipse-jee-4.5-win32-x64 tomcat版本:apache-tomcat-7.0.63-windows-x64 jd ...

  8. eclipse: eclipse创建java web项目

    Eclipse创建java web工程 eclipse版本:eclipse-jee-4.5-win32-x64 tomcat版本:apache-tomcat-7.0.63-windows-x64 jd ...

  9. 使用Java EE 在eclipse 开发动态的Web工程(Java web项目)

    1.使用Java EE 在eclipse 开发动态的Web工程(Java web项目)1)开发开发选项切换到JavaEE2)可以在Windows->show view中找到package exp ...

随机推荐

  1. elasticsearch(lucene)索引数据过程

    倒排索引存储-分段存储(lucene的功能)在lucene中:lucene index包含了若干个segment在elasticsearch中:index包含了若干主从shard,shard包干了若干 ...

  2. Windows10系统配置telnet服务的方法

    通常情况下,Windows10正式版系统的telnet服务都是处于关闭状态的,需要我们手动开启才可以.telnet服务可以调试端口,其重要性不容小视.今天,系统城小编就教大家如何配置telnet服务. ...

  3. Python3基础之正则表达式

    正则表达式 在线测试工具 http://tool.chinaz.com/regex/ 同一个位置上可以出现的字符的范围. 字符组 : [字符组] 在同一个位置可能出现的各种字符组成了一个字符组,在正则 ...

  4. shiro中ecache-core版本引起的异常

    ecache-core包版本不对引起的错误,将2.5.3换成2.4.5就好了 来源 WARN [RMI TCP Connection(3)-127.0.0.1] - Exception encount ...

  5. oracle问题之SYSTEM表空间不足 (二)

    杂症二.SYSTEM表空间不足报错 一.杂症: PLSQL登录,报错: ORA-00604: 递归 SQL 层  出现错误 ORA-01653: 表.无法通过(在表空间中)扩展 ORA-02002: ...

  6. Vue使用better-scroll左右菜单联动

    说明 最近想做一个vue商城小项目,练习一下vue的语法,刚刚好碰到了需要左右菜单实现联动,因此就接触了 better-scroll. github地址 中文文档. 代码 页面结构以及数据 //页面结 ...

  7. 解决git报错:error: RPC failed; curl 18 transfer closed with outstanding read data remaining 的方法

    报错信息: error: RPC failed; curl 18 transfer closed with outstanding read data remainingfatal: the remo ...

  8. 7.场景5:使用Linux桥的VRRP(L3HA)的高可用性

    此场景描述了使用ML2插件和Linux网桥的OpenStack网络服务的高可用性实现. 他的高可用性实施例增强了这样的场景:具有Linux网桥架构的传统使用了keepalived的虚拟路由器冗余协议( ...

  9. PAT基础编程练习

    7-1 厘米换算英尺英寸 (15 分)   如果已知英制长度的英尺foot和英寸inch的值,那么对应的米是(.现在,如果用户输入的是厘米数,那么对应英制长度的英尺和英寸是多少呢?别忘了1英尺等于12 ...

  10. 一文读懂什么是一致性hash算法

    Hash,一般翻译做散列.杂凑,或音译为哈希,是把任意长度的输入通过散列算法变换成固定长度的输出,该输出就是散列值.这种转换是一种压缩映射,也就是,散列值的空间通常远小于输入值的空间,不同的输入可能会 ...