Skip to main content
adicionou 2189 caracteres ao conteúdo
Fonte Link

Alguémspring-context.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: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.0.xsd
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">

<context:component-scan base-package="controller" />
<mvc:annotation-driven />

 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>


</beans>

web.xml

 <web-app 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"
     version="3.0"
     metadata-complete="true">
  <servlet>
 <servlet-name>springmvc</servlet-name>
 <servlet-class>
org.springframework.web.servlet.DispatcherServlet
 </servlet-class>
 <init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
  /WEB-INF/spring-context.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>
</web-app>

antes o web.xml estava na versão 2.3, porém troquei de versão, a ide começou a dar problemas, então compilei e gerei o package por fora com maven, a compilação e o package são gerados sem mensagens de erro, fiz deploy manualmente do .war no tomcat7, porém o erro persiste. Alguém já passou por esse problema??

Alguém já passou por esse problema??

spring-context.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: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.0.xsd
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">

<context:component-scan base-package="controller" />
<mvc:annotation-driven />

 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>


</beans>

web.xml

 <web-app 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"
     version="3.0"
     metadata-complete="true">
  <servlet>
 <servlet-name>springmvc</servlet-name>
 <servlet-class>
org.springframework.web.servlet.DispatcherServlet
 </servlet-class>
 <init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
  /WEB-INF/spring-context.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>
</web-app>

antes o web.xml estava na versão 2.3, porém troquei de versão, a ide começou a dar problemas, então compilei e gerei o package por fora com maven, a compilação e o package são gerados sem mensagens de erro, fiz deploy manualmente do .war no tomcat7, porém o erro persiste. Alguém já passou por esse problema??

removeu 4 caracteres do conteúdo
Fonte Link

Estou desenvolvendo um projeto utilizando maven 3.2, Spring framework(módulo mvc), e buscas no banco de dados através de JDBC.

Estou desenvolvendo um projeto utilizando maven 3.2, Spring framework(módulo mvc), e buscas no banco de dados através de JDBC.

Estou desenvolvendo um projeto utilizando maven, Spring framework(módulo mvc), e buscas no banco de dados através de JDBC.

Fonte Link

Valor enviado para JSP via Model do Spring não aparece

Estou desenvolvendo um projeto utilizando maven 3.2, Spring framework(módulo mvc), e buscas no banco de dados através de JDBC.

Tenho o seguinte código no meu controller:

@RequestMapping("/authors/edit")
public String edit(Author author, Model model) {
    IAuthorDao dao = new JdbcAuthorDao();
    model.addAttribute("author",dao.findById(author));
    return "authors/edit";
}

edit.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Editar um autor</title>
</head>
<body>
<h3>Alterar ${author.name}</h3>
<form action="#" method="post">
   <label>Nome</label> 
   <input type="text" name="name" value="${author.name}" /> <br>
   <label>Email</label> 
   <input type="text" name="email" value="${author.email}" /> <br>
   <input type="hidden" value="${author.id}">
  <input type="submit" value="Alterar">
</form>

<form:errors path="author.name"/> <br>
<form:errors path="author.email"/>
</body>
</html>

Porém, quando verifico a JSP, o valor do model não é substituído pelas chaves, continuando ${author.name} A princípio imaginei que estaria faltando alguma dependência no projeto, mas não consegui descobrir qual...

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>br.com.ppazello</groupId>
<artifactId>librarium2</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>librarium2 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>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
</dependency>

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.32</version>
</dependency>

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

<dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

<!-- Hibernate-beanvalidator -->

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>4.3.0.CR1</version>
</dependency>

<dependency>
    <groupId>org.jboss.logging</groupId>
    <artifactId>jboss-logging</artifactId>
    <version>3.1.0.CR2</version>
</dependency>

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.0.0.GA</version>
</dependency>

<dependency>
    <groupId>com.fasterxml</groupId>
    <artifactId>classmate</artifactId>
    <version>1.1.0</version>
</dependency>

<!-- Spring -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>3.2.3.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-oxm</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-jpa</artifactId>
    <version>1.2.0.RELEASE</version>
</dependency>
<dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib</artifactId>
    <version>2.2</version>
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.7.0</version>
</dependency>

</dependencies>
<build>
   <finalName>librarium2</finalName>
</build>

Alguém já passou por esse problema??