我在使用springMVC+tomcat写一个项目,但是我在访问我的jsp页面时,在浏览器中显示为源码:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="flysky" prefix="flysky"%>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=100">
<title>酒店订阅服务</title></head>
<body>
<div>
<form action='/HostelBed/html/hotelBed/getRS' method="post" name="form1">
PageNumber:<input type="text" name="pageNumber" id="pageNumber" value="" /><br/>
CheckInDate:<input type="text" name="checkInDate" id="checkInDate" value="" /><br/>
CheckOutDate:<input type="text" name="checkOutDate" id="checkOutDate" value="" /><br/>
Destination:<input type="text" name="destination" id="destination" value="" /><br/>
RoomCount:<input type="text" name="roomCount" id="roomCount" value="" /><br/>
AdultCount:<input type="text" name="adultCount" id="adultCount" value="" /><br/>
ChildCount:<input type="text" name="childCount" id="childCount" value="" /><br/>
<input type="submit" name="" id="" value="submit" />
</form>
</div>
</body>
</html>
但是我访问html页面的时候他又是好的!所以我可以肯定是服务器端的问题。
我的web.xml配置如下:
<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/classes/springmvc/*.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>
<!-- <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> -->
<!-- 日志log4j的配置 -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>600000</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>javass.webapp.root</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<!-- springMVC的编码配置 -->
<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>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>/html/hotelBed.jsp</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>flysky</taglib-uri>
<taglib-location>/WEB-INF/tld/flysky.tld</taglib-location>
</taglib>
</jsp-config>
我的springmvc的配置文件是:<context:component-scan base-package="com.hostel.flysky"/>
<mvc:annotation-driven/>
<mvc:default-servlet-handler/>
<!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/html"/>
<property name="suffix" value=".jsp"/>
</bean>
我怀疑是不是因为springmvc有什么东西没有配置导致的,还是我的tomcat有问题,请指教!springmvcjsp源码无法解析
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="flysky" prefix="flysky"%>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=100">
<title>酒店订阅服务</title></head>
<body>
<div>
<form action='/HostelBed/html/hotelBed/getRS' method="post" name="form1">
PageNumber:<input type="text" name="pageNumber" id="pageNumber" value="" /><br/>
CheckInDate:<input type="text" name="checkInDate" id="checkInDate" value="" /><br/>
CheckOutDate:<input type="text" name="checkOutDate" id="checkOutDate" value="" /><br/>
Destination:<input type="text" name="destination" id="destination" value="" /><br/>
RoomCount:<input type="text" name="roomCount" id="roomCount" value="" /><br/>
AdultCount:<input type="text" name="adultCount" id="adultCount" value="" /><br/>
ChildCount:<input type="text" name="childCount" id="childCount" value="" /><br/>
<input type="submit" name="" id="" value="submit" />
</form>
</div>
</body>
</html>
但是我访问html页面的时候他又是好的!所以我可以肯定是服务器端的问题。
我的web.xml配置如下:
<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/classes/springmvc/*.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>
<!-- <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> -->
<!-- 日志log4j的配置 -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>600000</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>javass.webapp.root</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<!-- springMVC的编码配置 -->
<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>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>/html/hotelBed.jsp</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>flysky</taglib-uri>
<taglib-location>/WEB-INF/tld/flysky.tld</taglib-location>
</taglib>
</jsp-config>
我的springmvc的配置文件是:<context:component-scan base-package="com.hostel.flysky"/>
<mvc:annotation-driven/>
<mvc:default-servlet-handler/>
<!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/html"/>
<property name="suffix" value=".jsp"/>
</bean>
我怀疑是不是因为springmvc有什么东西没有配置导致的,还是我的tomcat有问题,请指教!springmvcjsp源码无法解析
解决方案 »
- SSH项目全注解怎么写拦截器啊,注意是用注解写啊
- JAVA代码实现POST数据到指定网址(下班前结贴)
- 点击eclipse的时候这儿那么让它弹出选择了哪个文件夹为工程的目录。给与提示
- 我的eclipse在使用的过程中出现了问题
- 请问一下,微博中一个用户一个命名空间是怎么实现的啊
- 我想把显示数据的页面删除一条选中的记录,然后再在这个页面中显示出来,请问该怎么做呢?
- 又是一个继承的问题。
- 如何作一个动态网站的站内搜索引擎
- 做出html静态代码后,如果采用struts的话?
- jsp页面连接数据库不能及时刷新问题?请各位大侠不吝赐教!
- java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO
- web.xml的配置问题
另外,如果还不行的话,试试:
InternalResourceViewResolver bean 标签下加上:
<property name="contentType" value="text/html;charset=UTF-8" />
<servlet-name>springmvc</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
我找到我的问题所在了,要把这里的”/*“换成.do就可以了,或者在家一段配置用来配置静态资源的访问,就可以了
具体的原因我还没有找到,但我想应该是这些的静态资源的配置出现的了问题,谢谢各位的解答。