- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 spring mvc 中编写一个程序,但出现错误。这是程序
index.jsp
<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<jsp:directive.page contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="false"/>
<jsp:output doctype-root-element="html"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
omit-xml-declaration="true" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Welcome</title>
</head>
<body>
<a href="welcome">Welcome Guest</a>
</body>
</html>
</jsp:root>
HelloController.java
package java4s;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.ui.ModelMap;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.ArrayList;
import java.util.List;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import java4s.EmployeeService;
@Controller
public class HelloController {
@Autowired
EmployeeService emp_service;
@RequestMapping("/welcome")
public ModelAndView helloWorld(@ModelAttribute("userForm") Employee employee, ModelMap model) {
String message = "Welcome to Java4s.com Spring MVC 4.1.1 Sessions";
message += "<br>You Did it....!";
List<String> professionList = new ArrayList();
professionList.add("Developer");
professionList.add("Designer");
professionList.add("IT Manager");
model.put("professionList", professionList);
return new ModelAndView("welcomePage", "welcomeMessage", new Employee());
}
@RequestMapping(value = "/addemployee", method=RequestMethod.POST)
@DateTimeFormat(pattern="MM/dd/yyyy")
public ModelAndView submitForm(ModelMap model, @ModelAttribute("userForm") Employee employee/*, BindingResult errors*/) {
/*if(errors.hasErrors())
{
model.addAttribute("studenterrors", "Errorsssss");
}*/
//System.out.println(student.getBirthdate());
//model.addAttribute("studenterrors", "Errorsssss");
model.addAttribute("username", employee.getUsername());
model.addAttribute("password", employee.getPassword());
model.addAttribute("birthdate", employee.getBirthdate());
model.addAttribute("email", employee.getEmail());
model.addAttribute("professionList", employee.getProfession());
model.addAttribute("userForm", new Employee());
emp_service.saveData(employee);
return new ModelAndView("RegisterSuccess",model);
}
}
EmployeeServiceImpl.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package java4s;
import java4s.Employee;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* @author Harshit Shrivastava
*/
public class EmployeeServiceImpl implements EmployeeService {
@Autowired
DataSource dataSource;
@Override
public void saveData(Employee employee)
{
String query = "INSERT INTO EmployeeInfo(userid,username,firstname,lastname,mobileno,emailid,password,profession) VALUES(?,?,?,?,?,?,?,?)";
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
}
}
欢迎-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
xmlns:mvc="http://www.springframework.org/schema/mvc">
<context:component-scan base-package="java4s" />
<mvc:annotation-driven />
<bean id="EmployeeService" class="java4s.EmployeeServiceImpl" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="oracle.jdbc.pool.OracleDataSource"
p:url="jdbc:oracle:thin:@localhost:1521:IM"
p:username="user"
p:password="pass" />
</beans>
每当我提交表单时,都会收到此错误。错误:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from ServletContext resource [/WEB-INF/welcome-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 27; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.
最佳答案
将您的 xml 更改为 http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
如下。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="java4s" />
<mvc:annotation-driven />
<bean id="EmployeeService" class="java4s.EmployeeServiceImpl" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="oracle.jdbc.pool.OracleDataSource"
p:url="jdbc:oracle:thin:@localhost:1521:IM"
p:username="user"
p:password="pass" />
</beans>
关于java - Spring MVC 匹配通配符严格错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34891460/
最近我遇到了 AngularJS Strict DI 模式。使用它的目的和好处是什么?通过在移动设备上使用它,我们会获得显着的性能提升吗? 我尝试将它应用到我的代码中,并且在编写代码时我没有做任何注释
要在复制文本的底部添加额外信息 - 我想使用以下 JS: document.addEventListener('copy', (event) => { const pagelin
Java 是否有一个好的、严格 的日期解析器?我可以访问 Joda-Time,但我还没有看到这个选项。我发现了“Is there a good date parser for Java”这个问题,虽然
在下面的网页中,图像和 div 之间有几个像素的间隙。 (我已经在 Firefox 3 和 Safari 4 中测试过。) 我怎样才能缩小差距? body { background-color:
前段时间我遇到了一个“问题”,但我一直没有弄清楚。希望有人能照亮它。当我将 DOCTYPE 从严格更改为过渡时,是什么导致某些浏览器(Chrome、Opera 和 Safari)以不同方式呈现页面。我
PHP 以其类型杂耍而闻名。我必须承认这让我很困惑,而且我很难在比较中找出基本的逻辑/基本内容。 例如:如果 $a > $b 为真且 $b > $c 为真,是否意味着 $a > $c总是也是真的吗?
有在ECMAScript Language Specification11.9.1 等于运算符 (==): NOTE 3 The equality operator is not always tra
考虑这些不同的尝试,比如 last : Prelude> import Data.Foldable Prelude Data.Foldable> foldr const undefined (reve
我正在考虑使用 jQuery 元数据插件。看起来很有趣,但是... ... alert($('li.someclass').metadata().some); 这段代码有效吗? 更新 当然这是一个老例
我有一个 CSS 文件,我的本地开发服务器(webpack)正在提供一个显然错误的 mime 类型。 Refused to apply style from 'http://localhost:100
因此对于 Google Chrome 和 Opera,cookie 具有 SameSite 属性,该属性可以具有以下两个值之一:strict 或 lax。 它们之间的一些区别之一是 SameSite=
我试图到处寻找这个问题的答案,但似乎我运气不好。 我有一个非常简单的 Mongoose 模型 var userObject = { profile: { username: {
我正在为必须使用 XHTML 1.0 Strict 进行验证的类编写程序。根据 w3 的验证程序,我的页面通过了验证。我还有一个 HTML5 版本(这是原始版本),它可以按应有的方式进行验证和工作。
我得到了很多 validation errors因为 在 里面。如果我删除 br 标签,那么它工作正常。 为什么会产生问题? 最佳答案 不是br在p里面,而是你没有结束 br与 /特点。你有 在代码中
好吧,这让我抓狂。 我想在我的文档周围加上边框。它应该很好地绕过整个窗口/视口(viewport)。所以我定义: body { border: 1px solid red; } 当我的文档处于 q
我在 MySql 服务器上运行的查询遇到问题。这是查询: SELECT itms.Gender,itms.Age, (CASE WHEN (plv.Discount = 0 OR t1.EverGre
我有以下 javascript 函数,如果所有必填字段都不完整并且是我使用 Google Apps 脚本创建的表单的一部分,它会阻止表单提交。请注意,#submitbutton 实际上是一个常规按钮,
我是一名优秀的程序员,十分优秀!