我在struts 1应用程序中遇到以下情况。
应用程序的旧功能与struts 1一起使用,并具有以下servlet映射(我认为这是标准的处理方式)。
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
我还在struts 1中使用struts Actions编写了一些新功能(json webservices)。
我希望这些网址在没有.do扩展名的情况下可用,但旧网址仍然可以使用* .do扩展名。
我尝试了几个像/ url模式这样的东西,但这会破坏静态资源的加载。
有谁知道怎么做?
答案 0 :(得分:0)
我以不同的方式解决了这个问题。我用tuckey url rewriter来实现我的目标。
http://www.tuckey.org/urlrewrite/
我让重写器重定向
服务/ someService parma1 =值1&安培; param2的=值2 至 severices.someService.do?parma1=value1¶m2=value2
urlrewrite.xml中的配置如下所示
public class LedgerItemResult
{
public string Id { get; set; }
public DateTime CreatedDate { get; set; }
public string ProTeriaCustomerId { get; set; }
public string Collection { get; set; }
public int Count { get; set; }
}
public class LedgerItemsFromLedgerItemsAndOrdersGroupById : AbstractMultiMapIndexCreationTask<LedgerItemResult>
{
public LedgerItemsFromLedgerItemsAndOrdersGroupById()
{
AddMap<LedgerItem>(
ledgeritems => from ledgeritem in ledgeritems
where (decimal)ledgeritem.Amount < 0m
select new
{
Id = ledgeritem.Id,
CreatedDate = ledgeritem.TimeStamp,
ProTeriaCustomerId = ledgeritem.ProTeriaCustomerId,
Collection = MetadataFor(ledgeritem)["Raven-Entity-Name"].ToString(),
Count = 1
}
);
AddMap<Order>(
orders => from order in orders
from orderline in order.OrderLines
from ledgeritemid in orderline.LedgerItemIds
select new
{
Id = ledgeritemid,
CreatedDate = order.CreatedDateTime,
ProTeriaCustomerId = order.ProTeriaCustomerId,
Collection = MetadataFor(order)["Raven-Entity-Name"].ToString(),
Count = 1
}
);
Reduce = results =>
from result in results
group result by result.Id into g
select new LedgerItemResult
{
Id = g.First().Id,
CreatedDate = g.First().CreatedDate,
ProTeriaCustomerId = g.First().ProTeriaCustomerId,
Collection = g.First().Collection,
Count = g.Sum(x => x.Count)
};
Stores.Add(x => x.Id, FieldStorage.Yes);
Stores.Add(x => x.CreatedDate, FieldStorage.Yes);
Stores.Add(x => x.ProTeriaCustomerId, FieldStorage.Yes);
Stores.Add(x => x.Collection, FieldStorage.Yes);
MaxIndexOutputsPerDocument = 250;
}
}
其他信息可以在手册中找到。