50分求助 springmvc 页面跳转问题
新开发的小项目,第一次用springmvc 没用几天,遇到不少问题,现在这个问题实在自己解决不了,该看的帖子都看了,有些理解有些不理解,但都尝试过了,可就是无法实现页面跳转,以下是代码,请大神找出问题:
controller代码,同一controller之间调转
@Controller
@RequestMapping("/tbasCorp")
public class TbasCorpController {
@Resource(name="tbasCorpMgr")
private TbasCorpBulletinboardMgr tbasCorpMgr;
@RequestMapping("getTbasCorpByCode")
public String getTbasCorpByCode(String corpcode) {
System.out.println(corpcode);
TbasCorpBulletinboard tbasCorp = tbasCorpMgr.getTbasCorpByCode(corpcode);
return "redirect:/tbasCorp/initForHistory";
}
@RequestMapping("/initForHistory")
public String initForHistoryForData(String corpcode) {
System.out.println(corpcode);
Map<String, List> dataMap = tbasCorpMgr.initForHistory(corpcode);
dataMap.get("dislist");
dataMap.get("corplist");
dataMap.get("sitelist");
return "/enterpriseInfo";
}
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>json_test</display-name>
<welcome-file-list>
<welcome-file>/login.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:config/spring/spring-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.png</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:config/spring/spring-mvc.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>
<filter>
<filter-name>encodingFilter</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>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>openSession</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>openSession</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
spring-mvc.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/beans
http://www.springframework.org/schema/beans/spring-beans.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">
<!-- 注解扫描包 -->
<context:component-scan base-package="*" />
<!-- 开启注解 -->
<mvc:annotation-driven />
<!-- 定义视图解析器 -->
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html" />
<entry key="spring" value="text/html" />
<entry key="json" value="application/json" />
</map>
</property>
<property name="viewResolvers">
<list>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean
class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
</list>
</property>
</bean>
<!-- 静态资源(js/image)的访问 -->
<mvc:resources mapping="/js/**" location="/WebContent/js/" cache-period="31556926"/>
<mvc:resources mapping="/css/**" location="/WebContent/css/" cache-period="31556926"/>
<mvc:resources mapping="/images/**" location="/WebContent/images/" cache-period="31556926"/>
</beans>
现在的问题是getTbasCorpByCode方法已执行完成,最后return的时候页面无任何反应,需要填转到的initForHistory也并没有执行。
我将return "redirect:/tbasCorp/initForHistory";改为
return "/enterpriseInfo";
注:enterpriseInfo是jsp页面
在线等,请各位援手帮助
[解决办法]
只有这个不能跳转,还是所有的都不能跳转。
[解决办法]