V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  huang1102  ›  全部回复第 1 页 / 共 1 页
回复总数  2
想要 springboot 支持 jsp 的话可以在 pom.xml 加入
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
2018-09-30 18:05:57 +08:00
回复了 stephCurry 创建的主题 Java SpringMVC 的 Controller 怎么就直接注入 HttpSession 了?
你应该有在 web.xml 配置了监听 , 才能在普通类中直接注入这个
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

spring Mvc 要接收参数有: 1 HttpServletRequest 2 HttpServletResponse 3 HttpSession 4 Model 5 请求参数
可以不用注入的

@Controller
public class MyController{

// @Autowired
// private HttpSession session;

@RequestMapping("/hello")
//你漏了方法名称
public String helloWorld(HttpSession session){
return "hello world";
}
}
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5771 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 02:49 · PVG 10:49 · LAX 19:49 · JFK 22:49
Developed with CodeLauncher
♥ Do have faith in what you're doing.