你能给我一个简短的解释和一个@PathVariable在春季mvc 使用的样品吗?请详细说明您输入网址的方式?
我正在努力获得正确的网址来显示jsp页面.谢谢.
不推荐使用HibernatePersistence.class.该代码的替代方案应该是什么?
import org.hibernate.ejb.HibernatePersistence
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource());
entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
entityManagerFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
entityManagerFactoryBean.setJpaProperties(hibProperties());
return entityManagerFactoryBean;
}
Run Code Online (Sandbox Code Playgroud) 输出显示$ {message}而不是"Spring".
是否需要依赖来显示我的消息的价值?
我已经使用过Spring MVC,但我使用的是xml配置.我在这里错过了什么吗?希望你能帮助我解决这个问题.
<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>
<scope>provided</scope>
</dependency>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
调节器
package com.jwlayug.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class ControllerA {
@RequestMapping(value = "/hello")
public String printHello(Model model) {
model.addAttribute("message", "Spring");
System.out.println("this method is called!");
return "hellow";
}
}
Run Code Online (Sandbox Code Playgroud)
配置
package com.jwlayug.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import …Run Code Online (Sandbox Code Playgroud)