新手求救eclipse启动程序断点不停首页还是旧的,刷新页面才停并换成新的

s_h_w 2013-07-17 01:15:17
最近在学习spring mvc


——————————Controller代码————————————————
package test.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import test.service.PersonService;

@Controller
public class PersonController {

@Autowired
private PersonService personService;

@RequestMapping("index")
public ModelAndView index(HttpSession session,HttpServletRequest request)
{
ModelAndView mav=new ModelAndView();//断点在这行,启动应用断点不停,点右键刷新页面断点才停,控制台均没有报错
try
{
mav.setViewName("person");
}
catch(Exception e)
{
mav.setViewName("error");
}
return mav;
}
}
—————————————jsp代码———————————————————
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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">

</head>
<body>
person//我把这个换成aaa,重启应用,结果显示的还是person,右键点刷新页面,才换成aaa
</body>
</html>

——————————————————————————

为什么右键刷新页面才调index方法?请各位大侠看看怎么回事,哪里设置的不对吗?
还有,我想在PersonController 里定义一个变量name=“abc”,然后传到前台显示,java文件和jsp文件分别需要写什么代码?
...全文
202 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
失落夏天 2013-07-18
  • 打赏
  • 举报
回复
引用 8 楼 u011430760 的回复:
[quote=引用 7 楼 AA5279AA 的回复:] 清空浏览器缓存之后再打开看看。。 楼主,以后描述问题准确一点。刚开始我真的理解偏了。
清除缓存以后正常了,一启动断点也进去了,不会每次调试之前都要清缓存吧[/quote] 缓存的存在是为了提高访问速度。 楼主如果不想每次都设置的话,修改一下浏览器设置默认不保存缓存应该就行了。。 每种浏览器设置方式不一样,这个百度下吧
s_h_w 2013-07-18
  • 打赏
  • 举报
回复
引用 7 楼 AA5279AA 的回复:
清空浏览器缓存之后再打开看看。。 楼主,以后描述问题准确一点。刚开始我真的理解偏了。
清除缓存以后正常了,一启动断点也进去了,不会每次调试之前都要清缓存吧
失落夏天 2013-07-18
  • 打赏
  • 举报
回复
引用 4 楼 u011430760 的回复:
[quote=引用 3 楼 AA5279AA 的回复:] 你服务器启动的时候,页面是不会发生改变的。 只有页面发生请求之后,服务器作出相应,页面才会进行改变。 另外加载和调用时两码事啊。 加载了person.jsp并不一定等于调用啊。
可是我已经把person.jsp里显示的内容改了(把person变成aaa),重启tomcat,为什么还显示person啊?[/quote] 清空浏览器缓存之后再打开看看。。 楼主,以后描述问题准确一点。刚开始我真的理解偏了。
s_h_w 2013-07-18
  • 打赏
  • 举报
回复
引用 10 楼 u011405885 的回复:
请问怎样清除缓存?怎样修改浏览器设置默认不保存缓存?
工具-internet选项-常规里面 点删除清除缓存 点设置,单选框选择“每次访问网页时”
s_h_w 2013-07-18
  • 打赏
  • 举报
回复
哦,好了,谢谢各位了
pleasanton 2013-07-18
  • 打赏
  • 举报
回复
请问怎样清除缓存?怎样修改浏览器设置默认不保存缓存?
s_h_w 2013-07-17
  • 打赏
  • 举报
回复
引用 5 楼 a87345293 的回复:
你的服务器是重启了,但是它没有通知浏览器,你的浏览器怎么知道你的服务器重启了?
我停了server后,把eclipse里的那个IE窗口关了啊 然后修改的person.jsp代码 然后点debug on server 然后eclipse编译,控制台显示Server startup in 7542 ms 最后,eclipse自动又在里打开一个新的IE,是嵌在eclipse内部的,显示内容还是原来的内容,刷新后才变成新改的
明悟 2013-07-17
  • 打赏
  • 举报
回复
你的服务器是重启了,但是它没有通知浏览器,你的浏览器怎么知道你的服务器重启了?
s_h_w 2013-07-17
  • 打赏
  • 举报
回复
引用 3 楼 AA5279AA 的回复:
你服务器启动的时候,页面是不会发生改变的。 只有页面发生请求之后,服务器作出相应,页面才会进行改变。 另外加载和调用时两码事啊。 加载了person.jsp并不一定等于调用啊。
可是我已经把person.jsp里显示的内容改了(把person变成aaa),重启tomcat,为什么还显示person啊?
失落夏天 2013-07-17
  • 打赏
  • 举报
回复
引用 2 楼 u011430760 的回复:
[quote=引用 1 楼 AA5279AA 的回复:] 启动时根本就不调用那方法,哪来的断点呢
不调他怎么找到person.jsp的呢? 不是通过设置mav.setViewName("person");? 我没有index.html,只有person.jsp和error.jsp 下面是我的web.xml和servlet.xml —————————web.xml————————————————— <?xml version="1.0" encoding="UTF-8"?> <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"> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext.xml, /WEB-INF/config/applicationContext-*.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>shwtest</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>shwtest</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> ——————————————test-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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" 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"> <mvc:annotation-driven /> <context:component-scan base-package="test.web"></context:component-scan> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:viewClass="org.springframework.web.servlet.view.JstlView" p:prefix="/WEB-INF/webapp/" p:suffix=".jsp"> </bean> </beans>[/quote] 你服务器启动的时候,页面是不会发生改变的。 只有页面发生请求之后,服务器作出相应,页面才会进行改变。 另外加载和调用时两码事啊。 加载了person.jsp并不一定等于调用啊。
s_h_w 2013-07-17
  • 打赏
  • 举报
回复
引用 1 楼 AA5279AA 的回复:
启动时根本就不调用那方法,哪来的断点呢
不调他怎么找到person.jsp的呢? 不是通过设置mav.setViewName("person");? 我没有index.html,只有person.jsp和error.jsp 下面是我的web.xml和servlet.xml —————————web.xml————————————————— <?xml version="1.0" encoding="UTF-8"?> <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"> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext.xml, /WEB-INF/config/applicationContext-*.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>shwtest</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>shwtest</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> ——————————————test-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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" 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"> <mvc:annotation-driven /> <context:component-scan base-package="test.web"></context:component-scan> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:viewClass="org.springframework.web.servlet.view.JstlView" p:prefix="/WEB-INF/webapp/" p:suffix=".jsp"> </bean> </beans>
失落夏天 2013-07-17
  • 打赏
  • 举报
回复
启动时根本就不调用那方法,哪来的断点呢

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧