- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在netbeans中使用spring mvc框架构建一个项目当我使用<mvc:annotation-driven\>
时在project-servlet.xml中项目部署失败
我的代码是
i_am_alive-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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<context:annotation-config />
<!--<mvc:annotation-driven/>-->
<context:component-scan base-package="i_am_alive.web" />
<bean id="viewResolver2"
class="org.springframework.web.servlet.view.UrlBasedViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean>
</beans>
当我评论时<mvc:annotation-driven\>
项目部署成功,但没有进行验证,如果我取消注释 <mvc:annotation-driven\>
项目部署失败添加用户表单.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<form:form action="adduser.htm" modelattribute="user" commandName="user" method="post" >
<table>
<tr>
<td>Username</td>
<td><form:input path="username"/></td>
<td><form:errors path="username"/></td>
</tr>
<tr>
<td>Email</td>
<td><form:input path="email"/></td>
<td><form:errors path="email"/></td>
</tr>
<tr>
<td>Password</td>
<td><form:input path="password"/></td>
<td><form:errors path="password"/></td>
</tr>
</table>
<input type="submit" value="Sign Up" id="btn_sigup"/>
</form:form>
</body>
</html>
AddUserFormController.java 包 i_am_alive.web;
import i_am_alive.models.user_account_info;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class AddUserFomController {
@RequestMapping(value="/adduserform" , method=RequestMethod.GET)
public String showAddUserForm(ModelMap map){
map.addAttribute("user",new user_account_info());
return "adduserform";
}
@RequestMapping(value="/adduser" , method=RequestMethod.POST)
public String addUserDetail(@ModelAttribute(value="user") user_account_info user,BindingResult result){
if(result.hasErrors()){
return "adduserform";
}
return "redirect:/welcome.htm";
}
@RequestMapping(value="/welcome" , method=RequestMethod.GET)
public String welcomeUser(){
return "welcome";
}
}
欢迎.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page session="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<c:out value="${username}"/>
<c:out value="${user.email}"/>
<c:out value="${user.password}"/>
</body>
</html>
applicationcontext.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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
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.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-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/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/classes/jdbc.properties" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}" />
</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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/i_am_alive-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>i_am_alive</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>i_am_alive</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location>
</taglib>
user_account_info.java
package i_am_alive.models;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.GenerationType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.Email;
@Entity
public class user_account_info implements java.io.Serializable{
private long user_account_info_id;
@NotNull @Size(min=6,max=20)
private String username;
@NotNull @Email
private String email;
@NotNull
private String password;
private int role_id;
private String activation_link;
private int account_act_dact;
private String account_dor;
private int account_dirty;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
public long getUser_account_info_id() {
return user_account_info_id;
}
public void setUser_account_info_id(long user_account_info_id) {
this.user_account_info_id = user_account_info_id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getRole_id() {
return role_id;
}
public void setRole_id(int role_id) {
this.role_id = role_id;
}
public String getActivation_link() {
return activation_link;
}
public void setActivation_link(String activation_link) {
this.activation_link = activation_link;
}
public int getAccount_act_dact() {
return account_act_dact;
}
public void setAccount_act_dact(int account_act_dact) {
this.account_act_dact = account_act_dact;
}
public String getAccount_dor() {
return account_dor;
}
public void setAccount_dor(String account_dor) {
this.account_dor = account_dor;
}
public int getAccount_dirty() {
return account_dirty;
}
public void setAccount_dirty(int account_dirty) {
this.account_dirty = account_dirty;
}
@Override
public int hashCode() {
int hash = 7;
hash = 97 * hash + (int) (this.user_account_info_id ^ (this.user_account_info_id >>> 32));
hash = 97 * hash + (this.username != null ? this.username.hashCode() : 0);
hash = 97 * hash + (this.email != null ? this.email.hashCode() : 0);
hash = 97 * hash + (this.password != null ? this.password.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final user_account_info other = (user_account_info) obj;
if (this.user_account_info_id != other.user_account_info_id) {
return false;
}
if ((this.username == null) ? (other.username != null) : !this.username.equals(other.username)) {
return false;
}
if ((this.email == null) ? (other.email != null) : !this.email.equals(other.email)) {
return false;
}
if ((this.password == null) ? (other.password != null) : !this.password.equals(other.password)) {
return false;
}
return true;
}
}
消息.属性
NotNull.username=Username cannot be left blank;
NotNull.email=Username cannot be left blank;
NotNull.password=Username cannot be left blank;
错误信息
Incrementally deploying `http://localhost:9090/i_am_alive`
Completed incremental distribution of `http://localhost:9090/i_am_alive`
Incrementally redeploying `http://localhost:9090/i_am_alive`
Start is in progress...
start?path=/i_am_alive
FAIL - Application at context path /i_am_alive could not be started
K:\Advance_Java_Program\i_am_alive\nbproject\build-impl.xml:1039: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 4 seconds)
error log
Jan 13, 2014 11:12:12 AM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing WebApplicationContext for namespace 'i_am_alive-servlet': startup date [Mon Jan 13 10:19:00 IST 2014]; parent: Root WebApplicationContext
Jan 13, 2014 11:12:12 AM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@e81070: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,addUserFomController,loginController,viewResolver2,viewResolver,messageSource,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1da137e
Jan 13, 2014 11:12:12 AM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing Root WebApplicationContext: startup date [Mon Jan 13 10:18:58 IST 2014]; root of context hierarchy
Jan 13, 2014 11:12:12 AM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1da137e: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,addUserFomController,loginController,viewResolver2,viewResolver,messageSource,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
Jan 13, 2014 11:12:13 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
Jan 13, 2014 11:12:13 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
Jan 13, 2014 11:12:13 AM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Jan 13, 2014 11:12:13 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Mon Jan 13 11:12:13 IST 2014]; root of context hierarchy
Jan 13, 2014 11:12:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/i_am_alive-servlet.xml]
Jan 13, 2014 11:12:14 AM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 21 in XML document from ServletContext resource [/WEB-INF/i_am_alive-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 29; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 29; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:449)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3228)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1908)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:757)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:353)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2715)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:240)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:300)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 21 more
最佳答案
您尚未在 i_am_alive-servlet.xml
文件中指定 MVC 架构的 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:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
这只是您的i_am_alive-servlet.xml
的片段
您需要将其添加到 xmlSchemaDefinition
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
我认为它应该有效。话虽如此,您不想用版本来限定您的模式定义吗?
我发现您的applicationContext.xml使用了3.0版本。但是您的 i_am_alive-servlet.xml (即 WebAppContext)将使用 4.0 xml 架构进行验证。
我建议您在 i_am_alive-servlet.xml 中也使用相同的架构定义。
这将是
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
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.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-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/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
我指出的另一点是,您有一个 applicationContext.xml 文件,在我看来,该文件从未加载,因为您指定了 context-param 标记,该标记会覆盖并查找 i_am_alive-servlet.xml 文件作为应用程序语境。在您当前的情况下,您不需要 web.xml 中的以下标记片段
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/i_am_alive-servlet.xml</param-value>
</context-param>
如果您确实想维护自定义文件,那么也可以,但是您也有一个 applicationContext.xml,因此不需要加载根上下文。另外,还有一个拼写错误,您需要的文件是 application*C*ontext.xml。没有小C我还没试过。
如果您希望调度程序 servlet 加载 WebApplicationContext,则默认位置为/WEB-INF,默认文件名为 -servlet.xml。这是 i_am_alive-servlet.xml。因此,您也不需要指定自定义 Web 应用程序上下文文件。
如果您确实必须这样做,则上下文参数不是执行此操作的正确位置。应该是这样的
<servlet>
<servlet-name>i_am_alive</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/i_am_alive-servlet.xml</param-value>
</init-param>
</servlet>
但是,就像我提到的,您的 i_am_alive-servlet.xml
会被自动检测到,因为它是 Spring 容器将搜索的默认名称和位置。
关于java - 使用 <mvc :annotation-driven/> application is not deploy by tomcat in netbeans 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21084225/
我是 DDD 的初学者。 我不知道谁负责 API 请求的流程。 我不知道谁负责间接依赖于基础设施层的功能。 如带有 Web API 请求的函数。 例如我正在创建在线购物系统,系统支持取消订单。 我想我
我有一个dispatcher-servlet.xml和一个applicationContext.xml。 我一直在做一些重构,并感动 从dispatcher-servlet.xml到applica
哪些工具可用于元建模? 特别是开发图表编辑器,目前正在试用Eclipse GMF 想知道还有哪些其他选择? 有什么可比性吗? 最佳答案 由于许多方面,您的问题对于单一答案来说太宽泛了。 首先,元建模不
我前段时间学习了决策树和决策表。我觉得决策表可以帮助处理条件 If-Then-Else 语句。特别是,我觉得决策表没有副作用,例如,如果您没有注意到您还需要一个“else if”语句。 但我不确定如何
我们的团队开始实现事件驱动设计。我们现在正在确定记录这些事件的模式的最佳工具和实践是什么。 用于此用例的常用工具有哪些? 任何链接或建议表示赞赏。 最佳答案 我将从常见的 CloudEvents sp
我听说过最小化代码和最大化数据的概念,并且想知道其他人在构建自己的系统时如何/为什么应该这样做的建议? 最佳答案 通常,数据驱动的代码更易于阅读和维护。我知道我已经看到数据驱动被极端化并且最终变得非常
我的工作任务是为物流应用程序编写详细的工程计划,我们正在编码该计划以向客户提出建议。有人告诉我这是一个数据驱动的应用程序。对于应用程序来说,“数据驱动”意味着什么?相反的是什么?尽管在网络搜索时我可以
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗?更新问题,使其仅关注一个问题 editing this post . 关闭 4 年前。 Improve this que
我是 DDD 的新手。现在我在看领域事件。我不确定我是否正确理解了这个领域事件,但我只是在想如果领域事件发布失败会发生什么? 我这里有一个案例。当买家从我的网站订购商品时,首先我们将创建一个对象,Or
当我在我的软件项目中实践 DDD 时,我一直面临这样的问题:“为什么我应该在实体中实现我的业务规则?它们不应该是纯数据模型吗?” 请注意,根据我对 DDD 的理解,域模型可以由持久模型和值对象组成。
我有一个名为 Campaigns 的聚合,每个聚合都有一个名为 campaign 的根实体,这个根实体有一个尝试列表(实体) public class Attempts: IEntity
我正在尝试使用分层架构实现 DDD 应用程序。我有: 基础架构层 - 实现应用程序特定技术部分的层。 领域层——包含领域模型的层。 应用层 - 包含与域模型交互的干扰的层。 和接口(interface
最近学习ddd,里面说两个相关的bounded context之间的关系是upstream和downstream。 但是有没有可能在一种情况下A是上游B是下游,而在另一种情况下B是上游又是下游? 但是
我有一个名为 Order 的实体,以及一个聚合根 OrderManager,它根据来自应用层的请求更新订单状态和一些其他信息(AppLayer 调用 OrderManager,OrderManager
让我们假设场景: 我们有系统的用户 每个 User 都有他们的 Clients(Client 总是分配给一个且只有一个 User)< Users 上传不同的 Documents 并且 Document
这是一个 ASP.NET MVC 网站。 在领域驱动设计之后,我们有一个服务层。我们的 Controller 要求应用程序服务类执行各种任务,然后将结果路由到 View 。 业务逻辑由服务类执行。 例
不,这不是重复问题。我有很多关于这个主题的资源,但我仍然觉得我没有完全理解它。 这是我目前掌握的关于什么是聚合和聚合根的信息(来自多个来源,无论是文章、视频等...): 聚合是多个值对象\实体引用和规
我正在重建一个会计软件。该软件可以处理多种类型的交易,例如销售、库存补货和费用。我没有会计背景,但我在网上学到了一些概念。我正在尝试根据这些原则对域进行建模: 一个日记账分录由几条记录组成,每条记录要
我正在从头开始学习 DDD 主题,在许多 DDD 示例中,我看到“存储库接口(interface)”位于域中。这个存储库的真正目的是什么/它到底做了什么或解决了什么问题?这与持久层实现是否对应或有某种
假设我们有以下内容: DDD聚合了A和B,A可以引用B。 管理 A 的微服务公开以下命令: 创建一个 删除 A 链接 A 到 B 取消 A 与 B 的链接 管理 B 的微服务公开以下命令: 创建 B
我是一名优秀的程序员,十分优秀!