@Controller
public class HelloController {
@RequestMapping(value="/greeting")
public String sayHello(Model model) {
model.addAttribute("greeting","Hello World");
return "hello";
}
}
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="com.Controller"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
下面的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<servlet>
<servlet-name>anchorMailServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/servlet-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>anchorMailServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<display-name>Archetype Created Web Application</display-name>
</web-app>
下面的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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>AnchorMail</groupId>
<artifactId>AnchorMail</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>AnchorMail Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>AnchorMail</finalName>
</build>
</project>
看看这个配置元素:
<servlet-mapping>
<servlet-name>anchorMailServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
请注意您创建的配置。
以*.html结尾的请求被转发到spring dispatcher servlet。
我正在使用Eclipse和Gradle。Twilio被列为依赖项。所有版本都是最新的。引用Gradle的代码将无法编译,并返回Twilio类不存在的错误消息。在线代码令人沮丧地过时了。我希望这里有人能帮忙。 我正在运行的代码非常基本:
当我加上 遇到错误 找不到DefaultConfig_Enterprise{name=main,dimension=null,minsdkversion=defaultapiversion{mapilevel=14,mcodeName='null'},targetsdkversion=defaultapiversion{mapilevel=30,mcodeName='null'},rendersc
问题内容: 我创建了一个整数列表,并试图返回特定值的索引。该数组是3,8,2,5,1,4,7,6并且我想返回indexOf(3),应该为0。 导入java.util。*后,我在Eclipse Java Scrapbook中尝试了以下操作: 我也尝试过: 两者都返回-1。为什么?如何使它按预期工作? 问题答案: 它不是为了使它起作用。
问题内容: 为什么在使用sudo时找不到命令“ bundle”: 但是在不使用sudo时确实存在: 我问的原因是我正在关注https://github.com/gitlabhq/gitlab- recipes/tree/master/install/centos ,它指出要使用sudo。 所述添加标志…引发’bundle:命令未找到’错误,但显示“此帐户当前不可用”。 问题答案: 使用和不检查的值
为什么在使用sudo时找不到命令"bundle": 但不使用sudo时不存在: 我问的原因是我在https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos,它表示使用sudo。 我尝试添加一个标志,如使用$sudo bundle exec所述。。。引发“bundle:command not found”错误,但获取“此
当我将数据插入到分配表中时,除了硬件和软件值,它们的编码方式与其他值完全相同,其他值都可以正常工作。我就是不明白。 这项工作: 但是,当我尝试包括硬件或软件的值时,例如: 我只得到以下错误:SQL错误:ORA-02291:完整性约束(JAS1224。SYS_C0028418)违反-找不到父密钥02291. 00000-"完整性约束(%s.%s)违反-找不到父密钥"*原因:外键值没有匹配的主键值。*