servelet dispatch时css和js丢失的问题

今天发现当用RequestDispatcher dispatch一个jsp的时候,css和js信息都会丢失,dispatch后路径已经变了!

解决方法:
1. 可以改用redirect, 但是效率好像太低,因为又要在client和server之间走一遍!
2. 可以hard code
<link rel=“stylesheet” href=“<%= request.getContextPath() %>/style.css” type=“text/css”>
这样的坏处就是有硬编码~ 不过效率比较高! 采用之!
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s